Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过maven运行testng测试时更改控制台输出_Java_Maven_Testng - Fatal编程技术网

Java 通过maven运行testng测试时更改控制台输出

Java 通过maven运行testng测试时更改控制台输出,java,maven,testng,Java,Maven,Testng,我通过maven运行TestNG测试,使用:mvn测试或mvn测试-Dtest=或mvn测试-Dgroups= 我希望将测试的大量输出存储在文件中,但我需要的控制台输出如下: TestA.test1-通过 TestA.test2-失败 TestB.test11-通过 我实现了一个监听器,它实现了ITestListener和put System.out.println(消息); 为每个方法提供合适的消息。 在pom.xml中,我添加了一个插件: <plugin> <gro

我通过maven运行TestNG测试,使用:
mvn测试
mvn测试-Dtest=
mvn测试-Dgroups=

我希望将测试的大量输出存储在文件中,但我需要的控制台输出如下:

TestA.test1-通过
TestA.test2-失败
TestB.test11-通过

我实现了一个监听器,它实现了ITestListener和put System.out.println(消息); 为每个方法提供合适的消息。 在pom.xml中,我添加了一个插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.9</version>
    <configuration>
        <properties>
            <property>
                <name>listener</name>
                <value><my listener full name class></value>
            </property>
        </properties>
    </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
2.9
听众
但似乎没有任何响应,同样的输出不断地出现在控制台上


知道我做错了什么吗?我希望通过
mvn test
继续运行我的测试,但将输出更改为更有条理。

如果希望侦听器为每个测试工作,则在测试类中导入错误。您的pom.xml应该如下所示:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
            <configuration>
                <properties>
                    <property>
                        <name>usedefaultlisteners</name>
                        <value>false</value>
                    </property>
                    <property>
                        <name>listener</name>
                        <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter
                        </value>
                    </property>
                </properties>
            </configuration>
        </plugin>

org.apache.maven.plugins
maven surefire插件
2.21.0
usedefaultlisteners
假的
听众
org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter
您应该禁用默认侦听器以使用自定义侦听器