0

我根据以下层次结构创建了一些 JUnit 测试用例。

包名例如:

test.qa.paramter.myTest

在这个包下,我有 2 个测试用例:

1:带有@Test注解的第一个测试用例(类名为NormalTest,方法名为caseNormalTest)

2:第二个测试用例(类名称为RepeatTest,方法名称为caseRepeatTest)与@RepeatedTest,它将使用不同的输入值重复相同的测试2次。

我的问题是如何获得与@RepeatedTest 相同的类名xml 输出,因为它不显示完整的包名。还有可能在万无一失的报告中获得重复计数吗?

现在,当我使用 Jenkins 运行测试用例时,maven-surefire-plugin 为 @RepeatedTest 生成测试结果 xml

<testcase name="caseRepeatTest" classname="caseRepeatTest()" time="30.636"/>
<testcase name="caseParametrization" classname="caseParametrization()" time="13.013"/>

而对于@Test annoation 我得到

<testcase name="caseNormalTest" classname="test.qa.paramter.myTest.NormalTest" time="22.796"/>

下面是我的 POM 设置

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <forkCount>1</forkCount>
        <reuseForks>false</reuseForks>
        <argLine>-Xms512m -Xmx2048m</argLine>
        <testFailureIgnore>true</testFailureIgnore>
        <systemPropertyVariables>
         <sun.net.http.allowRestrictedHeaders>true</sun.net.http.allowRestrictedHeaders>
            <testInstance>v1</testInstance>
        </systemPropertyVariables>
        <includes>
            <include></include>
        </includes>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.3.2</version>
        </dependency>
    </dependencies>
</plugin>
4

1 回答 1

0

升级到 Maven Surefire 2.22.0 或更高版本并删除对过时的junit-platform-surefire-provider.

此处的详细信息:https ://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven

于 2019-09-27T14:38:02.650 回答