我将插件中的所有测试排除在我的测试套件之外:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<!--
<testFailureIgnore>true</testFailureIgnore>
<skipTests>true</skipTests>
-->
<parallel>both</parallel>
<threadCount>10</threadCount>
<forkMode>once</forkMode>
<configuration>
<excludes>
<exclude>**/Test*.java</exclude>
<exclude>**/*Test.java</exclude>
<exclude>**/*TestCase.java</exclude>
</excludes>
<includes>
<include>ru.csbi.registry.CategorizedTestsSuite.java</include>
</includes>
</configuration>
<!--
<configuration>
<groups>ru.csbi.registry.IntegrationTestsNotRequiringContainerCategory</groups>
<groups>ru.csbi.registry.UnitTestsCategory</groups>
</configuration>
-->
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>
但所有测试都已执行。
即使我删除了我在配置中的唯一包含它仍然运行所有测试:
<configuration>
<excludes>
<exclude>**/Test*.java</exclude>
<exclude>**/*Test.java</exclude>
<exclude>**/*TestCase.java</exclude>
</excludes>
<!--
<includes>
<include>ru.csbi.registry.CategorizedTestsSuite.java</include>
</includes>
-->
</configuration>
这是日志:
----------------------------------------------- --------测试 -------------------------------------------------- -----并发配置为
parallel='both'
,perCoreThreadCount=true
,threadCount=10
,useUnlimitedThreads = false运行javalangtests.AnnotationTest
测试运行:2,失败:0,错误:0,跳过:0,经过的时间:0秒
运行ru.csbi.registry.services.JdbcServiceTest
测试运行:1,失败:0,错误:0,跳过:0,经过的时间:0秒
运行ru.csbi.registry.services.reflection.ClassServiceTest
测试运行:2,失败:0,错误:0,跳过:0,经过的时间:0秒
运行ru.csbi.registry.services.reflection.FieldServiceTest
测试运行:2,失败:0,错误:0,跳过:0,经过的时间:0秒
运行 ru.csbi.registry.services.reflection.hibernate.relation.RelationServiceTest
测试运行:7,失败:0,错误:0,跳过:0,已过去时间:0.016 秒
有效的pom:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<configuration>
<includes>
<include>ru.csbi.registry.CategorizedTestsSuite.java</include>
</includes>
</configuration>
</configuration>
</execution>
</executions>
<configuration>
<configuration>
<includes>
<include>ru.csbi.registry.CategorizedTestsSuite.java</include>
</includes>
</configuration>
</configuration>
</plugin>
答案 0 :(得分:4)
您需要从配置块中删除配置块。
像这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<!--
<testFailureIgnore>true</testFailureIgnore>
<skipTests>true</skipTests>
-->
<parallel>both</parallel>
<threadCount>10</threadCount>
<forkMode>once</forkMode>
<excludes>
<exclude>**/Test*.java</exclude>
<exclude>**/*Test.java</exclude>
<exclude>**/*TestCase.java</exclude>
</excludes>
<includes>
<include>ru.csbi.registry.CategorizedTestsSuite.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>
嵌套配置元素毫无意义。以及include中的包名称(ru.csbi.registry.CategorizedTestsSuite.java)。