英文:
Jenkins quits tests suddenly
问题
以下是翻译的内容:
我正在使用Java Maven从Jenkins执行TestNg测试,一切似乎都正常,但Jenkins会随机停止执行测试并提示:
[ERROR] 会话ID为空。在调用quit()后继续使用WebDriver?
构建信息:版本:'4.0.0-alpha-6',修订版本:'5f43a29cfc'
系统信息:主机:'******',IP:'172.**.**.**',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'11.0.8'
驱动程序信息:driver.version:RemoteWebDriver
[INFO]
[INFO] 结果:
[INFO]
[INFO] 运行的测试:0,失败:0,错误:0,跳过:0
[INFO]
[ERROR] 存在测试失败。
驱动程序信息:driver.version:RemoteWebDriver
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:733)
...
at java.base/java.lang.Thread.run(Thread.java:834)
[JENKINS] 正在记录测试结果
[Checks API] 找不到合适的检查发布者。
[INFO] ------------------------------------------------------------------------
[INFO] 构建成功
[INFO] ------------------------------------------------------------------------
[INFO] 总时间:45:28 分钟
[INFO] 完成时间:2020-09-30T17:33:07+02:00
[INFO] ------------------------------------------------------------------------
当我在我的笔记本电脑上运行测试时,这种情况不会发生(Jenkins位于Windows虚拟机上)。
是什么原因导致了这个问题呢?
<details>
<summary>英文:</summary>
I am executing TestNg tests with Java Maven from Jenkins and everything seems to be okay but Jenkins stops executing the tests randomly and prompts:
[ERROR] Session ID is null. Using WebDriver after calling quit()?
Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc'
System info: host: '******', ip: '172.**.**.**', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: RemoteWebDriver
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[ERROR] There are test failures.
Driver info: driver.version: RemoteWebDriver
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:733)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:305)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:265)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1314)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1159)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:932)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.jvnet.hudson.maven3.launcher.Maven35Launcher.main(Maven35Launcher.java:130)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at jenkins.maven3.agent.Maven35Main.launch(Maven35Main.java:178)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:139)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
[JENKINS] Recording test results
[Checks API] No suitable checks publisher found.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45:28 min
[INFO] Finished at: 2020-09-30T17:33:07+02:00
[INFO] ------------------------------------------------------------------------
This does not happen when i run the tests in my laptop (jenkins is on a windows vm).
What could cause this problem?
</details>
# 答案1
**得分**: 0
```xml
我的可靠配置:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myProject</groupId>
<artifactId>myProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>anotherJavaProject</groupId>
<artifactId>anotherJavaProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
这是 testng.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listeners>
<listener class-name="listeners.TestNGListeners"></listener>
</listeners>
<test name="test1">
<parameter name="package" value="registration" />
<parameter name="iterationstorun" value="1,2" />
<parameter name="resource" value="src/main/resources/excel/test1.xlsx" />
<parameter name="browser" value="chrome" />
<parameter name="exitonfail" value="no" />
<parameter name="email" value="yes" />
<classes>
<class name="utils.Class" />
</classes>
</test>
<test name="test2">
<parameter name="package" value="registration" />
<parameter name="iterationstorun" value='1,2' />
<parameter name="resource" value="src/main/resources/excel/test2.xlsx" />
<parameter name="browser" value="chrome" />
<parameter name="exitonfail" value="no" />
<classes>
<class name="utils.Class" />
</classes>
</test>
</suite>
英文:
My surefire:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myProject</groupId>
<artifactId>myProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>anotherJavaProject</groupId>
<artifactId>anotherJavaProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
and this is the testng.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listeners>
<listener class-name="listeners.TestNGListeners"></listener>
</listeners>
<test name="test1">
<parameter name="package" value="registration" />
<parameter name="iterationstorun" value="1,2" />
<parameter name="resource"
value="src/main/resources/excel/test1.xlsx" />
<parameter name="browser" value="chrome" />
<parameter name="exitonfail" value="no" />
<parameter name="email" value="yes" />
<classes>
<class name="utils.Class" />
</classes>
</test>
<test name="test2">
<parameter name="package" value="registration" />
<parameter name="iterationstorun" value='1,2' />
<parameter name="resource"
value="src/main/resources/excel/test2.xlsx" />
<parameter name="browser" value="chrome" />
<parameter name="exitonfail" value="no" />
<classes>
<class name="utils.Class" />
</classes>
</test>
</suite>
答案2
得分: 0
使用Eclipse运行测试时,我发现问题出现在extent报告中。
我认为问题可能是这个:https://github.com/anshooarora/extentreports-java/issues/497
Jenkins没有记录任何关于这个问题的信息:
java.lang.OutOfMemoryError: Java heap space
at java.base/java.lang.StringCoding$StringDecoder.decode(StringCoding.java:195)
at java.base/java.lang.StringCoding.decode(StringCoding.java:331)
at java.base/java.lang.String.<init>(String.java:592)
at java.base/java.lang.String.<init>(String.java:614)
at com.aventstack.extentreports.append.JsonDeserializer.deserialize(JsonDeserializer.java:27)
at com.aventstack.extentreports.append.RawEntityConverter.convertAndApply(RawEntityConverter.java:27)
at com.aventstack.extentreports.AbstractProcessor.convertRawEntities(AbstractProcessor.java:98)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:377)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:392)
at utils.ExcelDataProvider.test(ExcelDataProvider.java:126)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:821)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at org.testng.TestRunner$$Lambda$87/0x0000000100158840.accept(Unknown Source)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:588)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
英文:
Running the test with Eclipse I found out that the problem is in the extent report.
I think this is the issue: https://github.com/anshooarora/extentreports-java/issues/497
Jenkins wasn't logging anything of this:
java.lang.OutOfMemoryError: Java heap space
at java.base/java.lang.StringCoding$StringDecoder.decode(StringCoding.java:195)
at java.base/java.lang.StringCoding.decode(StringCoding.java:331)
at java.base/java.lang.String.<init>(String.java:592)
at java.base/java.lang.String.<init>(String.java:614)
at com.aventstack.extentreports.append.JsonDeserializer.deserialize(JsonDeserializer.java:27)
at com.aventstack.extentreports.append.RawEntityConverter.convertAndApply(RawEntityConverter.java:27)
at com.aventstack.extentreports.AbstractProcessor.convertRawEntities(AbstractProcessor.java:98)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:377)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:392)
at utils.ExcelDataProvider.test(ExcelDataProvider.java:126)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:821)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at org.testng.TestRunner$$Lambda$87/0x0000000100158840.accept(Unknown Source)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:588)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论