gpt4 book ai didi

maven Surefire 测试插件运行测试,即使它们被排除 :

转载 作者:行者123 更新时间:2023-12-02 07:35:07 39 4
gpt4 key购买 nike

我排除了插件中除我的测试套件之外的所有测试:

<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>

这是日志:

------------------------------------------------------- T E S T S ------------------------------------------------------- Concurrency config is parallel='both',perCoreThreadCount=true, threadCount=10, useUnlimitedThreads=false

Running javalangtests.AnnotationTest

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.JdbcServiceTest

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.reflection.ClassServiceTest

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.reflection.FieldServiceTest

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.reflection.hibernate.relation.RelationServiceTest

Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec

有效的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>

最佳答案

您需要从配置 block 中删除配置 block 。

像这样:

<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>

嵌套的配置元素没有任何意义。以及包含中的包名称 (ru.csbi.registry.CategorizedTestsSuite.java)。

关于maven Surefire 测试插件运行测试,即使它们被排除 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9461519/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com