In a commercial project that I did from scratch on my own, I divided the tests into a unit (which I called *Test.java ) and integration ( *IT.java ), in accordance with the policies of the Surefire and Failsafe plugin that I used to run the tests. Of course, they work much slower than UT.
This makes it possible to run a group of tests using simple commands: mvn test for UT and mvn integration-test for UT and IT, as well as the ability to skip only IT using mvn install -DskipITs .
Another good thing is the ability to be weaker with the results of integration tests, because they fail more often than unit tests due to environmental problems (i.e. the database starts too long, the message browser starts too soon and soon ) By default, a Failsafe test failure does not kill the assembly unless you explicitly specify "verify":
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>integration-test</id> <goals> <goal>integration-test</goal> </goals> </execution> </executions> </plugin>
source share