@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
...
})
public class Stories extends JUnitStories {
@Before
public void setUp() throws Exception {
configuredEmbedder()
// turn on parallel test execution
.useExecutorService(newFixedThreadPool(30, new ThreadFactoryBuilder()
.setDaemon(true)
.build()));
configuredEmbedder()
.embedderControls()
...
// don't use it this way not to produce multiThreading = true and delayed StoryReporter callbacks
// and you will see your application logging 'for each jbehave step'
// .useThreads(30);
}
@Override
public Configuration configuration() {
return new MostUsefulConfiguration()
...
.useStoryReporterBuilder(new StoryReporterBuilder()
...
.withFormats(HTML)
.withReporters(teamCityReporter));
}
}
# 1 楼答案
将应用程序的输出重新定向到std out(JBehave的输出已经存在)。注意
follow=true
每线程文件输出
在测试之前开始将线程输出重定向到文件,并在测试之后停止
在
启用并行JBehave执行
因此,每个并行测试都会有一个日志文件,其中既有测试输出,也有应用程序输出(只有测试运行线程执行的代码)
奖金-TeamCityReporter(JBehave-to-TC集成)将成功实时统计正在运行的并行测试,并在TC GUI上报告任何测试失败。将测试输出目录配置为TC工件路径,以访问每个测试输出