I'm probably not the first one to raise this topic on this mailing list but I'm really struggling to run stories concurrently.
It works but just partially. It creates any desired number of threads and then run stories in them but there are two main issues with this example:
* Race conditions
* thread that finishes last overwrites report results of other threads
I slightly modified the aforementioned "threads" example, here's a list of changes:
* it runs in IDE,
* made it independent from the parent "jbehave-examples" project
* report resources are upnacked when running from CLI
* extended useStoryTimeoutInSecs to 60s
* moved stories from src/main/java/org/jbehave/examples/threads/stories to src/main/resources/stories as StoryFinder couldn't locate them!
To run tests from CLI:
mvn clean install
(This will also unpack all the report resources)
To run them in IDE (tested with Intelij Idea) simply right click on "ThreadsStories" class and select run.
(btw. this won't unpack report resources, so the report will be missing all the styling, but if you run "mvn install" first and then re-run tests from IDE all the resources will be still in place and only report files will get updated :) )
To change number of threads:
if you're going to use CLI, then define # of threads in pom.xml
in case you prefer running tests in IDE:
Set the # of threads in the "ThreadsStories" class constructor.
I'd appreciate any help to build a properly working example of a multi-threading jbehave project, with no race condition issues and the one that also generates a proper report.
btw. Here's an excerpt from the log showing the race condition problem
Scenario: scenario with examples
Maria starts counting to 5
Maria says 0 Mississippi (after 0 s)
Failed to run story stories/another_long.story
Maria says 1 Mississippi (after 1 s)
Maria says 2 Mississippi (after 2 s)
Maria says 3 Mississippi (after 3 s)
Maria says 4 Mississippi (after 4 s)