我使用jBehave和WebDriver创建了一些测试。
当我通过Maven执行它们时,执行是secuencially:
TEST 1
TEST 2
...
我有兴趣同时执行测试。根据文件,这是可能的。
http://jbehave.org/reference/stable/multi-threading.html
我已经尝试将符号添加到“Stories”类,并且还使用threads = 5执行了mvn命令,但是不起作用。
@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
是否可以同时执行多个测试?
编辑:
添加了maven执行部分:
<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>
答案 0 :(得分:2)
您的问题可能包含更多细节,但我假设您使用的是run-stories-as-embeddables目标。你基本上有两个选择:
使用run-stories-as-embeddables目标时,将属性“threads”设置为目标。从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>
使用run-stories-with-annotated-embedder maven目标,该目标应该遵循Annotation
此外,您在上面描述的两个方案必须是两个单独的故事。多线程只发生在故事层面。同一故事中的场景不是多线程执行的。
答案 1 :(得分:0)
使用Spring JUnit测试运行器.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)));
}
...