7

I have some tests created with jBehave and WebDriver.

When I execute them via Maven, the execution is secuencially:

TEST 1

  • Open navigator
  • Execute all the steps of the first story
  • Close navigator

TEST 2

  • Open navigator
  • Execute all the steps of the second story
  • Close navigator

...

I'm interested in execute the tests simultaneously. According the documentation, this is possible.

http://jbehave.org/reference/stable/multi-threading.html

I've tried adding the notation to the "Stories" class, and also executed the mvn command with the threads=5, but doesn't work.

    @UsingEmbedder(threads=5)
    public class EtsyDotComStories extends JUnitStories {

    ...
    @Override
    protected List<String> storyPaths() {
    return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(), asList("**/*.story"), null);

    }

        }


 mvn clean install -s settings.xml -Pjava-spring,codehaus,threads=5

Is it possible to execute multiple tests simultaneously?

EDIT:

Added the maven execution part:

<plugins>
      <plugin>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-maven-plugin</artifactId>
        <version>${jbehave.core.version}</version>
        <executions>
          <execution>
            <id>embeddable-stories</id>
            <phase>integration-test</phase>
            <configuration>
              <includes>
                <include>**/*Stories.java</include>
              </includes>
              <ignoreFailureInStories>true</ignoreFailureInStories>
              <ignoreFailureInView>false</ignoreFailureInView>
              <threads>5</threads>
              <executorsClass>org.jbehave.core.embedder.executors.SameThreadExecutors</executorsClass>
            </configuration>
            <goals>
              <goal>run-stories-as-embeddables</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>11.0.1</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
Dr. No
  • 1,306
  • 5
  • 28
  • 57
  • Could you please also share part of your pom, to see how you launch JBehave? Does the EtsyDotcomStories contain more configuration than what you posted? – AndreasEK Apr 16 '13 at 09:16
  • @AndreasEK Added the part of pom that is executed. If you need more information let me know. Thanks. EtsyDotcomStories doesn't have more notations but there is a lot of code inside. If you need, I can try to add in the question. – Dr. No Apr 18 '13 at 08:29

2 Answers2

3

Your question could contain a little more detail, but I assume that you are using run-stories-as-embeddables goal. You basically have two options:

  1. When using the run-stories-as-embeddables goal, set the property "threads" to the goal. Extending the example from the Maven Gaols documentation:

    <plugin>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-maven-plugin</artifactId>
        <version>[version]</version>
        <executions>
            <execution>
                <id>run-stories-as-embeddables</id>
                <phase>integration-test</phase>
                <configuration>
                    <includes>
                        <include>**/*Stories.java</include>
                    </includes>
                    <ignoreFailureInStories>true</ignoreFailureInStories>
                    <ignoreFailureInView>false</ignoreFailureInView>
                    <treads>5</threads>
                </configuration>
                <goals>
                    <goal>run-stories-as-embeddables</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    
  2. Use the run-stories-with-annotated-embedder maven goal, which should respect the Annotation

Also, the two scenarios that you describe above have to be in two seperate stories. Mutli-threading only happens on story-level. Scenarios inside the same story are not executed multi-threaded.

AndreasEK
  • 363
  • 1
  • 10
  • Yes I'm using run-stories-with-annotated-embedder goal. Only for clarification, what means "two seperate stories". I have only one stories class (EtsyDotComStories) and this calls all the stories. Every stories is in a different story file. It's correct? – Dr. No Apr 18 '13 at 08:33
  • Yes, I meant storys as in story files. All scenarios in one story (file) will be executed on one thread. – AndreasEK May 17 '13 at 10:12
0

With Spring JUnit test runner .useThreads(20)

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
    ...
})
public class Stories extends JUnitStories {

    @Before
    public void setUp() throws Exception {
        configuredEmbedder()
                .embedderControls()
                ...
                .useThreads(20)
                .useStoryTimeouts(Integer.toString(maxIfDebugOr(1800)));
    }
...
Mike
  • 20,010
  • 25
  • 97
  • 140