So this project has the standard JSP, XML, etc. structure
-
using the Spring Context to...
-
Test the auto wiring of beans (EJB)
-
Test the setting of active profiles
-
Spring Test Configuration
-
JUnit 4 and JUnit 5
-
-
Spring MVC Test is used for testing interactions with Spring MVC Controllers
-
Provides Servlet API Mock objects to mock the web environment
-
-
- Very light weight - ideal for unit tests
- Tests one controller at a time
- Allows for testing of controller requests and responses
-
- Loads larger context of Spring Configuration
- Tests many controllers - per configuration
- Allows for testing of application config
-
-
Spring MVC Test uses a "fluent" API via several static imports
-
Spring MVC Test does not use a running Servlet container
-
No network request is made (ie to port 80 or 8080)
-
HTML is not generated, thus templates are not executed (JSP, Thymeleaf, etc.)
-
You can test the view (template) requested, or redirected to
- but cannot test expected HTML to be rendered as a result
-
Spring does support testing with a running container when needed
-
-
All source code examples in the repository are for my Online Course - Testing Spring Beginner to Guru
This source code repository contains JUnit 5 and Spring Framework Testing examples.
The main source code is a copy of the Spring Framework Pet Clinic project. This is a reference project using a traditional 3-layer architecture without Spring Boot.
- Should use Java 11 or higher. Previous versions of Java are un-tested.
- Use Maven 3.6.0 or higher
After cloning this repo, from the project root run:
./mvnw jetty:run-war
For questions and help:
- Please post in course
- Or post in the Slack Community exclusive to the course.
GitHub Issues will not be addressed.