[ERROR] Failed to execute goal > o-6ren">
gpt4 book ai didi

java - 使用 maven 运行 testng 套件 xml 时 maven-surefire-plugin 中的 NullPointerException

转载 作者:行者123 更新时间:2023-12-05 07:44:03 26 4
gpt4 key购买 nike

当我使用 maven 运行我的 testng 套件 xml 而套件标签中没有 parallel="tests"时,我遇到异常。

> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test
> (default-test) on project neo: Execution default-test of goal
> org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed:
> There was an error in the forked process [ERROR]
> java.lang.NullPointerException [ERROR] at
> java.util.Hashtable.put(Hashtable.java:514) [ERROR] at
> java.util.Properties.setProperty(Properties.java:161) [ERROR] at
> org.testng.reporters.JUnitXMLReporter.createElement(JUnitXMLReporter.java:203)
> [ERROR] at
> org.testng.reporters.JUnitXMLReporter.generateReport(JUnitXMLReporter.java:181)
> [ERROR] at
> org.testng.reporters.JUnitXMLReporter.onFinish(JUnitXMLReporter.java:118)
> [ERROR] at org.testng.TestRunner.fireEvent(TestRunner.java:1246)
> [ERROR] at org.testng.TestRunner.afterRun(TestRunner.java:1039)
> [ERROR] at org.testng.TestRunner.run(TestRunner.java:621) [ERROR] at
> org.testng.SuiteRunner.runTest(SuiteRunner.java:334) [ERROR] at
> org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) [ERROR]
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) [ERROR] at
> org.testng.SuiteRunner.run(SuiteRunner.java:240) [ERROR] at
> org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> [ERROR] at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> [ERROR] at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
> [ERROR] at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
> [ERROR] at org.testng.TestNG.run(TestNG.java:1031) [ERROR] at
> org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:281)
> [ERROR] at
> org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
> [ERROR] at
> org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:121)
> [ERROR] at
> org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
> [ERROR] at
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
> [ERROR] at
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)

当我使用 parallel="tests"运行它时,它工作正常。另外,如果我在没有 parallel="tests"的情况下从 eclipse“作为 testng 测试运行”运行我的 testng 套件 xml,它工作正常。请帮忙。

我的套件 xml-

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Filters API" parallel="tests">
<test name="Filters Test">
<classes>
<class name="com.api.testng.modules.filters.FiltersTests"/>
</classes>
</test>
</suite>

最佳答案

我提到插件的这部分 pom-

        <profile>
<id>TestNg</id>
<activation>
<property>
<name>run_tests</name>
<value>TestNg</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<testIncludes>
<testInclude>**/testng/**</testInclude>
</testIncludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
</argLine>
<properties>
<property>
<name>listener</name>
<value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>
${suite.xml}
</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>

关于java - 使用 maven 运行 testng 套件 xml 时 maven-surefire-plugin 中的 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43185366/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com