Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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 TestNG。将testng结果更改为不包含配置方法_Java_Maven_Logging_Configuration_Testng - Fatal编程技术网

Java TestNG。将testng结果更改为不包含配置方法

Java TestNG。将testng结果更改为不包含配置方法,java,maven,logging,configuration,testng,Java,Maven,Logging,Configuration,Testng,我正在尝试重新配置我的测试结果,以不显示配置方法的跳过结果&这会扭曲我的数据 我正在通过TestNG运行测试,其中每个方法都有@beforeMethod和@afterMethod配置方法。在before方法中,我检查@Test方法是否应该运行&如果不应该,我抛出一个SkipException来跳过它 在我目前的情况下,我运行了两种测试方法。一个被设置为失败,另一个被设计为跳过。所以我希望得到1次失败和1次跳过的结果。在IDE控制台中,这是我得到的结果,但是当我通过Maven运行它时,我得到1次

我正在尝试重新配置我的测试结果,以不显示配置方法的跳过结果&这会扭曲我的数据

我正在通过TestNG运行测试,其中每个方法都有@beforeMethod和@afterMethod配置方法。在before方法中,我检查@Test方法是否应该运行&如果不应该,我抛出一个SkipException来跳过它


在我目前的情况下,我运行了两种测试方法。一个被设置为失败,另一个被设计为跳过。所以我希望得到1次失败和1次跳过的结果。在IDE控制台中,这是我得到的结果,但是当我通过Maven运行它时,我得到1次失败和3次跳过。这是我的名片。失败的测试用例没有显示@beforeMethod或@afterMethod

我发现了IConfigurationListener,但不确定如何使用它从报告中删除配置方法。我也在使用maven surefire

这就是我目前所拥有的

public class MyConfigurationListenerAdapter implements IConfigurationListener {

    @Override
    public void onConfigurationSkip(ITestResult itr) {
        String configName = itr.getName();
        if (configName.equals("beforeMethod")||configName.equals("afterMethod")){
            //TODO remove itr from test result
        }
    }
}
pom.xml

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
       <version>2.14.1</version>
       <configuration>
           <properties>
               <property>
                   <name>listener</name>
                   <value>java_accelerator.testng.classes.MyConfigurationListenerAdapter</value>
               </property>
           </properties>
           <!-- Suite testng xml file to consider for test execution -->
           <suiteXmlFiles>
              <suiteXmlFile>src/test/java/testclasses/tests/testng.xml</suiteXmlFile>
           </suiteXmlFiles>
      </configuration>
  </plugin>

org.apache.maven.plugins
maven surefire插件
2.14.1
听众
java_accelerator.testng.classes.MyConfiguration ListenerAdapter
src/test/java/testclasses/tests/testng.xml
有人能帮我吗