【问题标题】:maven surefire plugin - specifying a single test - does NOT runmaven surefire 插件 - 指定单个测试 - 不运行
【发布时间】:2012-07-24 17:28:58
【问题描述】:

我有这个 Maven 配置文件设置。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.8</version>
    <configuration>
        <includes>
            <include>com.something.test.X.java</include>
        </includes>

        <properties>
            <property>
                <name>reporter</name>
                <value>org.testng.reporters.XMLReporter</value>
            </property>
            <property>
                <name>listener</name>                          
                <value>Listener</value>
            </property>
        </properties>

        <systemProperties>
            <property>
                <name>x.host</name>
                <value>${server.ip}</value>
            </property>
            <property>
                <name>http_port</name>
                <value>${http_port}</value>
            </property>
            <property>
                <name>https_port</name>
                <value>${https_port}</value>
            </property>
            <property>
                <name>jmx_remote_port</name>
                <value>${jmx_remote_port}</value>
            </property>
        </systemProperties>

        <systemPropertyVariables>
            <x.host>${server.ip}</x.host>
            <env.BUILD_NUMBER>${env.BUILD_NUMBER}</env.BUILD_NUMBER>
            <env.HOSTNAME>${env.HOSTNAME}</env.HOSTNAME>
        </systemPropertyVariables>
    </configuration>

    <executions>
        <execution>
            <id>test</id>
            <phase>integration-test</phase>
            <goals>
                <goal>test</goal>
            </goals>
            <configuration>
                <skip>false</skip>
            </configuration>
        </execution>
    </executions>
</plugin>

当我运行配置文件时,包含的测试不运行! 我究竟做错了什么?我什至用suitexmlfile尝试过,但我得到一个解析错误,它找不到类。

【问题讨论】:

  • 我不确定这会有所帮助(现在无法自己测试),但您可以尝试在include 部分中仅指定类名而不是完整类名(带包)。跨度>
  • 我确实尝试过。它不起作用。我基本上想运行其中一个集成测试而不是全部。我尝试过使用 、-Dtest.... 我现在没有想法了:(
  • 啊,我明白了。删除测试名称末尾的.java

标签: java maven testng maven-surefire-plugin


【解决方案1】:

正如 Andrew Logvinov 所建议的,您应该从包含的测试名称中删除 .java。一般情况下,测试坐标指定为&lt;class-name&gt;[#&lt;method-name&gt;]

【讨论】:

    猜你喜欢
    • 2021-12-18
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多