Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run in parallel mode with JUnit #86

Closed
aslakhellesoy opened this issue Nov 10, 2011 · 15 comments
Closed

Run in parallel mode with JUnit #86

aslakhellesoy opened this issue Nov 10, 2011 · 15 comments

Comments

@aslakhellesoy
Copy link
Contributor

See http://groups.google.com/group/cukes/msg/12ad0e5b2f2a846a

@awostenberg
Copy link

+1 this. Parallel runner is one of the tips outlined in specification by example to get quick feedback as collections of tests grow. Quick feedback amplifies learning.

@cgleissner
Copy link

This issue can be replicated via https://github.com/cgleissner/cucumber-jvm/tree/master/examples/java-parallel

Use mvn clean install -Pparallel to enable a parallel build of two tests, using two threads. The README.txt in that example project contains further details.

@tpesce
Copy link

tpesce commented Nov 10, 2011

+1 - I'd love to see this working.

@aslakhellesoy
Copy link
Contributor Author

I have updated your branch @cgleissner : master...java-parallel-example

Seems to be working fine now. So I guess as long as the user is properly partitioning what to run with several @Cucumber.Options(features = {.....}) they will be run in parallel. Please let me know if I'm missing something.

@cgleissner
Copy link

Hi Aslak,

I tried the parallelism feature and it works now, which is great. Thanks a
lot for your hard work on Cucumber-JVM!

Regards
Christian

On Mon, Mar 26, 2012 at 2:08 AM, Aslak Hellesy <
reply@reply.github.com

wrote:

I have updated your branch @cgleissner :
master...java-parallel-example

Seems to be working fine now. So I guess as long as the user is properly
partitioning what to run with several @Cucumber.Options(features = {.....}) they will be run in parallel. Please let me know if I'm missing
something.


Reply to this email directly or view it on GitHub:
#86 (comment)

Christian Gleissner, Senior Software Engineer
2560 55th St. | Boulder, Colorado 80301

P chris_gleissner (Skype)
www.tendrilinc.com | blog http://www.tendrilinc.com/category/blog/

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender.
Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.
Finally, the recipient should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus transmitted by this email.

@aslakhellesoy
Copy link
Contributor Author

Great - I'll close this then.

@cgleissner
Copy link

Hi Aslak,

the new feature works great with Surefire 2.10.

However, when I try to upgrade Surefire to 2.12, it fails. That new version
supports parallelism while forking the JVM, which is a very useful feature
to ensure completely de-coupled tests in non thread-safe code.

This occurs with JUnit 4.10 and Cucumber-JVM 1.0.0.RC24 under Apache Maven
3.0.4 and Java 1.6.0_29 on a Mac.

Example along with some logging in the step methods:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Concurrency config is parallel='classes', perCoreThreadCount=true,
threadCount=4, useUnlimitedThreads=false
log4j:ERROR Could not find value for key log4j.appender.FILE
log4j:ERROR Could not instantiate appender named "FILE".
08:12:42,152 INFO  [pool-1-thread-1     ] PersonalGrowthSteps :
thePersonExists(0.0) (instance: 0)
08:12:42,152 INFO  [pool-1-thread-2     ] PersonalGrowthSteps :
thePersonExists(0.0) (instance: 1)
08:12:42,153 INFO  [pool-1-thread-1     ] PersonalGrowthSteps :
thePersonGrowsBy(1.0) (instance: 0)
08:12:42,153 INFO  [pool-1-thread-2     ] PersonalGrowthSteps :
thePersonGrowsBy(1.0) (instance: 1)
08:12:42,154 INFO  [pool-1-thread-1     ] PersonalGrowthSteps :
thePersonWillBe(1.0) (instance: 0)
08:12:42,154 INFO  [pool-1-thread-2     ] PersonalGrowthSteps :
thePersonWillBe(1.0) (instance: 1)
08:12:42,155 INFO  [pool-1-thread-1     ] PersonalGrowthSteps :
thePersonExists(5.0) (instance: 2)
08:12:42,155 INFO  [pool-1-thread-2     ] PersonalGrowthSteps :
thePersonExists(5.0) (instance: 3)
08:12:42,156 INFO  [pool-1-thread-1     ] PersonalGrowthSteps :
thePersonGrowsBy(1.0) (instance: 2)
08:12:42,156 INFO  [pool-1-thread-2     ] PersonalGrowthSteps :
thePersonGrowsBy(1.0) (instance: 3)
08:12:42,157 INFO  [pool-1-thread-1     ] PersonalGrowthSteps :
thePersonWillBe(6.0) (instance: 2)
08:12:42,157 INFO  [pool-1-thread-2     ] PersonalGrowthSteps :
thePersonWillBe(6.0) (instance: 3)


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: org.apache.maven.surefire.testset.TestSetFailedException:
java.lang.NullPointerException; nested exception is
java.lang.NullPointerException: null
at
org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:166)
at
org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:63)
at
org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
... 9 more
Caused by: java.lang.NullPointerException
at
org.apache.maven.surefire.junitcore.ConcurrentReporterManager.testStarting(ConcurrentReporterManager.java:106)
at
org.apache.maven.surefire.common.junit4.JUnit4RunListener.testStarted(JUnit4RunListener.java:87)
at
org.junit.runner.notification.RunNotifier$3.notifyListener(RunNotifier.java:87)
at
org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:41)
at
org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:84)
at
org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:45)
at cucumber.junit.JUnitReporter.startExecutionUnit(JUnitReporter.java:43)
at cucumber.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:46)
at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:50)
at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:17)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at cucumber.junit.FeatureRunner.run(FeatureRunner.java:57)
at cucumber.junit.Cucumber.runChild(Cucumber.java:76)
at cucumber.junit.Cucumber.runChild(Cucumber.java:36)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at cucumber.junit.Cucumber.run(Cucumber.java:81)
at
org.apache.maven.surefire.junitcore.ClassDemarcatingRunner.run(ClassDemarcatingRunner.java:58)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2.831s
[INFO] Finished at: Mon Mar 26 08:12:42 MDT 2012
[INFO] Final Memory: 10M/554M
[INFO]
------------------------------------------------------------------------

@aslakhellesoy
Copy link
Contributor Author

Please create a new ticket for this, and please use GFM to format logs

@mrunalgosar
Copy link

Hi aslakhellesoy.. i have found a neater way of implementing cucumber jvm parallel runs. i have small POC ready.. Let me know how can i send it for review?

@aslakhellesoy
Copy link
Contributor Author

Just send a pull request or put it in a new repo on github.

@mrunalgosar
Copy link

Hi aslakhellesoy.. I've forked the project, added the POC related changes to the JUnit project and commited it to forked source here: https://github.com/mrunalgosar/cucumber-jvm.git. Look at package: cucumber.api.junit.parallel. Let me know your views if this approach is doable further, then i can work on the same and get this feature implemented properly.
Regards Mrunal

@mrunalgosar
Copy link

Hi aslakhellesoy.. I've forked the project, added the POC related changes
to the JUnit project and commited it to forked source here:
https://github.com/mrunalgosar/cucumber-jvm.git. Look at package:
cucumber.api.junit.parallel. Let me know your views on it. If this approach
is doable further, then i can work on the same and get this feature
implemented properly.
Regards Mrunal

On Fri, Nov 27, 2015 at 1:52 AM, Aslak Hellesøy notifications@github.com
wrote:

Just send a pull request or put it in a new repo on github.


Reply to this email directly or view it on GitHub
#86 (comment)
.

@aslakhellesoy
Copy link
Contributor Author

Many people use Cucumber without using the JUnit runner. Core functionality (such as parallel execution) should not depend on JUnit.

Another thing we need to handle well is results - if there are many threads running scenarios, the results should still be collected and reported in the same way as if there were only one thread.

We'll implement this our own way, based on Gherkin3's pickles.

@mrunalgosar
Copy link

Ok..sounds Fair enough.. i'll probably keep it in some kind of util and
share it if anyone is interested till the time gherkin3 comes alive.

Regards
Mrunal

On Sat, Nov 28, 2015 at 9:51 PM, Aslak Hellesøy notifications@github.com
wrote:

Many people use Cucumber without using the JUnit runner. Core
functionality (such as parallel execution) should not depend on JUnit.

Another thing we need to handle well is results - if there are many
threads running scenarios, the results should still be collected and
reported in the same way as if there were only one thread.

We'll implement this our own way, based on Gherkin3's pickles.


Reply to this email directly or view it on GitHub
#86 (comment)
.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants