I have two types of tests in my Java (Maven) web project: βregularβ unit tests and integration tests using the built-in Tomcat 7 server and Selenium to automatically test the GUI on Jenkins. All tests are annotated using JUnit @Test , normal tests end with "Test.java", and integration tests end with "IntegrationTest.java". All test classes are located in src / test / java
I usually create my project using mvn clean verify , while the corresponding part of my pom.xml , which starts the tomcat server and breaks up the test categories, looks like this:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <uriEncoding>UTF-8</uriEncoding> <additionalConfigFilesDir>${basedir}/conf</additionalConfigFilesDir> <contextFile>${basedir}/src/test/resources/context.xml</contextFile> </configuration> <executions> <execution> <id>start-tomcat</id> <phase>pre-integration-test</phase> <goals> <goal>run-war-only</goal> </goals> <configuration> <fork>true</fork> <port>9090</port> </configuration> </execution> <execution> <id>stop-tomcat</id> <phase>post-integration-test</phase> <goals> <goal>shutdown</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <configuration> <excludes> <exclude>**/*IntegrationTest*</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.16</version> <configuration> <includes> <include>**/*IntegrationTest*</include> </includes> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin>
This procedure works fine except when I want to run my tests in eclipse, where I usually right-click my project -> run as -> JUnit Tests. Selecting this option, all my tests (including integration tests) are run. In this case, the integration tests fail because Tomcat does not work (it runs only in the Maven pre-integration-test phase).
How can I exclude these tests in Eclipse using the JUnit plugin?
source share