serenity-bdd/serenity-cucumber-starter

Unable to use thread and fork count when executing in parallel

FrancisJoshuaCervantes opened this issue · 21 comments

Hi @wakaleo ,

Good day sir, I would like to ask on how can I configure parallel execution with defined thread.count and fork.count. On my end it is not working when I execute eh. I am using profile when I'm running in parallel. Although it is executing in parallel but the it does not recognize the defined thread and fork. Thank you.
Here is my config:

image

I tried following some of your git projects pom.xml configuration. I always get this error messages, and I don't know what to fix. I hope you can help me.

22:05:13.345 [main] INFO i.c.junit.CucumberSerenityRunner - Running slice 1 of 1 using fork 1 of 3 from feature paths feature.path]
22:05:13.370 [main] ERROR i.c.junit.CucumberSerenityRunner - Test failed to start
java.lang.NullPointerException: null
at java.util.HashMap.merge(HashMap.java:1225) ~[na:1.8.0_211]
at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320) ~[na:1.8.0_211]
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[na:1.8.0_211]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[na:1.8.0_211]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_211]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_211]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_211]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_211]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_211]
at net.serenitybdd.cucumber.suiteslicing.CucumberScenarioLoader.load(CucumberScenarioLoader.java:42) ~[serenity-cucumber5-2.2.0.jar:2.2.0]
at net.serenitybdd.cucumber.suiteslicing.CucumberSuiteSlicer.scenarios(CucumberSuiteSlicer.java:22) ~[serenity-cucumber5-2.2.0.jar:2.2.0]
at io.cucumber.junit.CucumberSerenityRunner.getChildren(CucumberSerenityRunner.java:285) ~[serenity-cucumber5-2.2.0.jar:2.2.0]
at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.filter(ParentRunner.java:379) [junit-4.12.jar:4.12]
at org.junit.runner.manipulation.Filter.apply(Filter.java:97) [junit-4.12.jar:4.12]
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37) [junit-4.12.jar:4.12]
at org.junit.runner.JUnitCore.run(JUnitCore.java:115) [junit-4.12.jar:4.12]
at org.testng.junit.JUnit4TestRunner.start(JUnit4TestRunner.java:81) [testng-6.8.jar:na]
at org.testng.junit.JUnit4TestRunner.run(JUnit4TestRunner.java:69) [testng-6.8.jar:na]
at org.testng.TestRunner$1.run(TestRunner.java:682) [testng-6.8.jar:na]
at org.testng.TestRunner.runWorkers(TestRunner.java:1012) [testng-6.8.jar:na]
at org.testng.TestRunner.privateRunJUnit(TestRunner.java:713) [testng-6.8.jar:na]
at org.testng.TestRunner.run(TestRunner.java:614) [testng-6.8.jar:na]
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) [testng-6.8.jar:na]
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) [testng-6.8.jar:na]
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) [testng-6.8.jar:na]
at org.testng.SuiteRunner.run(SuiteRunner.java:240) [testng-6.8.jar:na]
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [testng-6.8.jar:na]
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [testng-6.8.jar:na]
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) [testng-6.8.jar:na]
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) [testng-6.8.jar:na]
at org.testng.TestNG.run(TestNG.java:1031) [testng-6.8.jar:na]
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:135) [surefire-testng-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:112) [surefire-testng-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeLazy(TestNGDirectoryTestSuite.java:123) [surefire-testng-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:90) [surefire-testng-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:146) [surefire-testng-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377) [surefire-booter-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138) [surefire-booter-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465) [surefire-booter-3.0.0-M4.jar:3.0.0-M4]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451) [surefire-booter-3.0.0-M4.jar:3.0.0-M4]
org.testng.TestNGException:
Failure in JUnit mode for class ph.test.automation.runner.CucumberTestSuite
at org.testng.junit.JUnit4TestRunner.start(JUnit4TestRunner.java:105)
at org.testng.junit.JUnit4TestRunner.run(JUnit4TestRunner.java:69)
at org.testng.TestRunner$1.run(TestRunner.java:682)
at org.testng.TestRunner.runWorkers(TestRunner.java:1012)
at org.testng.TestRunner.privateRunJUnit(TestRunner.java:713)
at org.testng.TestRunner.run(TestRunner.java:614)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:135)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:112)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeLazy(TestNGDirectoryTestSuite.java:123)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:90)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:146)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)
Caused by: java.lang.NullPointerException
at java.util.HashMap.merge(HashMap.java:1225)
at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at net.serenitybdd.cucumber.suiteslicing.CucumberScenarioLoader.load(CucumberScenarioLoader.java:42)
at net.serenitybdd.cucumber.suiteslicing.CucumberSuiteSlicer.scenarios(CucumberSuiteSlicer.java:22)
at io.cucumber.junit.CucumberSerenityRunner.getChildren(CucumberSerenityRunner.java:285)
at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426)
at org.junit.runners.ParentRunner.filter(ParentRunner.java:379)
at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.testng.junit.JUnit4TestRunner.start(JUnit4TestRunner.java:81)
... 23 more

Those variables are for running distributed tests in batches; you can use the standard Failsafe configuration options for parallel execution (https://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html).

Those variables are for running distributed tests in batches; you can use the standard Failsafe configuration options for parallel execution (https://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html).

I already tried but I'm not yet successful. The failsafe only runs in single sequence not in parallel. I've already defined inside the pom. But it does not execute in parallel

Are you using Cucumber 5?

Are you using Cucumber 5?

Yes

See https://cucumber.io/docs/guides/parallel-execution/

Already tried that one. The only thing difference is i use maven-failsafe-version 3.0.0-m4

image

That is the correct configuration. But I see you have TestNG in your stack trace, and a dependency on surefire-juni47 in your pom; I'm not sure if that would affect things.

That is the correct configuration. But I see you have TestNG in your stack trace, and a dependency on surefire-juni47 in your pom; I'm not sure if that would affect things.

I removed the testNg dependency and it worked. But it does not suit the thread I defined. I executed all my feature files.

I don't understand your response.

I don't understand your response.

I defined threadCount = 2
image

But it executed 4 features because I have 4 features inside my feature package
image

threadCount = 2 means it will run all four of your features, in two parallel threads. Do you have a reason for believing this is not what it is doing?

threadCount = 2 means it will run all four of your features, in two parallel threads. Do you have a reason for believing this is not what it is doing?

I see so that's what it is. I'm sorry I thought it was for limiting the feature to be executed. Can I ask on how can I limit or configure on how many feature can I run in parallel?

What problem are you trying to solve?

What problem are you trying to solve?

I wanted to limit the execution of my feature into half or atleast try running in parallel by twos or threes

So you don't want to run all of your features?

So you don't want to run all of your features?

Yes, by batch or by specific count

threads=2 will run all of your feature files, spread out over multiple parallel threads: 2 threads per CPU core to be precise.

threads=2 will run all of your feature files, spread out over multiple parallel threads: 2 threads per CPU core to be precise.

I understand now. Thank you for your patience and helpful responses sir.

thread =2
To be precise it is thread per logical processors. In my system, it has 2 core and 4 logical processors. For thread =2, it ran 8 tests at once