TestNG-带有故障保护插件的自定义报告器侦听器问题
我有一个项目,其中我使用mavenTestNG-带有故障保护插件的自定义报告器侦听器问题,testng,maven-failsafe-plugin,Testng,Maven Failsafe Plugin,我有一个项目,其中我使用mavenfail-safeplugin来运行集成测试。我使用的是Maven+TestNG框架组合。出于项目目的,我在前面修改了TestNG的默认XML报告,以自定义项目需求 我在CustomReporter类中实现了上述要求,该类扩展了TestNG的IReporter接口。早些时候,我使用了surefire插件来运行这些测试方法,并在surefire插件中添加了侦听器机制 现在对于某些项目的需要,我需要迁移到故障保护插件。因此,通过配置POM文件,我绕过了test阶段执
fail-safe
plugin来运行集成测试。我使用的是Maven+TestNG
框架组合。出于项目目的,我在前面修改了TestNG的默认XML报告,以自定义项目需求
我在CustomReporter类中实现了上述要求,该类扩展了TestNG的IReporter
接口。早些时候,我使用了surefire
插件来运行这些测试方法,并在surefire插件中添加了侦听器机制
现在对于某些项目的需要,我需要迁移到故障保护插件。因此,通过配置POM文件,我绕过了test
阶段执行surefire
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
即使我在集成测试阶段使用了故障保护插件,我还是会遇到异常
使用:org.apache.maven.surefire
.TestNG.conf配置TestNG。TestNGMapConfigurator@ab50cd
org.apache.maven.surefire.util.`SurefireReflectionException
如何解决这个问题
注意:当我尝试使用surefire
插件执行测试时,侦听器机制按预期工作。事实上,问题在于与故障保护
和测试NG
版本的兼容性。我使用了testng5.9v
和故障保护插件2.12v
。这是问题的根本原因
我将Failsafe
版本降级为2.5v
,问题得到解决
感谢谷歌团队指导我从版本角度思考问题。
我遇到了同样的问题,尚未解决。有什么帮助吗?
<
plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>fail-safe-myplug</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<skip>false</skip>
<properties>
<property>
<name>listener</name>
<value>com.CustomXmlReport</value>
</property>
</properties>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Running com.myPack.AppTest
Configuring TestNG with: org.apache.maven.`surefire`.testng.conf.TestNGMapConfigurator@ab50cd
org.apache.maven.surefire.util.`SurefireReflectionException: java.lang.reflect.InvocationTargetException`; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: java.lang.IncompatibleClassChangeError: Expected static method org.testng.reporters.XMLReporterConfig.getTimestampFormat()Ljava/lang/String;
at com.myPack.CustomSuiteResultWriter.getTestResultAttributes(CustomSuiteResultWriter.java:175)
at com.myPack.CustomSuiteResultWriter.addTestResult(CustomSuiteResultWriter.java:138)
at com.myPack.CustomSuiteResultWriter.addTestResults(CustomSuiteResultWriter.java:117)
at com.myPack.CustomSuiteResultWriter.writeAllToBuffer(CustomSuiteResultWriter.java:76)
at com.myPack.CustomSuiteResultWriter.writeSuiteResult(CustomSuiteResultWriter.java:56)
at com.myPack.CustomXmlReportGenerator.writeSuiteToBuffer(CustomXmlReportGenerator.java:102)
at com.myPack.CustomXmlReportGenerator.writeSuite(CustomXmlReportGenerator.java:65)
at com.myPack.CustomXmlReportGenerator.generateReport(CustomXmlReportGenerator.java:42)
at org.testng.TestNG.generateReports(TestNG.java:780)
at org.testng.TestNG.run(TestNG.java:766)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:76)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:112)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:115)
... 9 more