-
Notifications
You must be signed in to change notification settings - Fork 70
Use integration testing
Here the project says "integration testing". Your team may call it by another name. This means bringing up your application, possibly with fakes, stubs, mocks, spies, dummies, or doubles for external dependencies (databases, other services, etc), and running tests against high-level functionality, but not starting up external dependencies themselves (ie, Docker, or manual command-line steps). Think of CI: what are called here "integration tests" are those which do not need your CI to provide other services.
An example is testing STDOUT
and STDERR
for a command-line application.
(If you are in Spring Framework/Boot-land, use controller tests for your REST
services.)
Unlike src/main/java
and src/test/java
, there is no generally agreed
convention for where to put integration tests.
This project keeps all tests regardless of type in src/test/java
for
simplicity of presentation, naming integration tests with "*IT.java".
A more sophisticated approach may make sense for your project.
If you'd like to keep your integration tests in a separate source root from unit tests, consider these plugins:
- For Gradle, use [native Gradle to add new test
Caution: This project duplicates
ApplicationIT.java
andApplicationTest.java
reflecting the split in philosophy between Gradle and Maven for integration tests. Clearly in a production project, you would have only one of these. sets](https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests). (Previous versions of this project used the excellenttestsets
plugin, however, it does not support Gradle 8) - For Maven, use the Maven Failsafe Plugin
Caution: This project duplicates
ApplicationIT.java
and
ApplicationTest.java
reflecting the split in philosophy between Gradle and Maven for integration
tests.
Clearly in a production project, you would have only one of these.
- For Maven projects, Apache maintains Failsafe and Surefire plugins as a pair,
and share the same version numbers.
This project uses a shared
maven-testing-plugins.version
property - Baeldung has a good introduction article on Maven Failsafe
See the code repo for working examples.
This work is dedicated/deeded to the public following laws in jurisdictions
for such purpose.
The principal authors are:
You can always use the "Pages" UI control above this sidebar ☝ to navigate around all pages alphabetically (even pages not in this sidebar), to navigate the outline for each page, or for a search box.
Here is the suggested reading order: