我在java文件中设置了以下代码:
@CucumberOptions(tags = {"~@ignore"})
public class ExamplesTest {
@BeforeClass
public static void before() {
System.setProperty("karate.env", "dev");
}
@Test
public void testParallel() {
String karateOutputPath = "target/surefire-reports";
KarateStats stats = CucumberRunner.parallel(getClass(), 1, karateOutputPath);
generateReport(karateOutputPath);
assertTrue("there are scenario failures", stats.getFailCount() == 0);
}
public static void generateReport(String karateOutputPath) {
Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
List<String> jsonPaths = new ArrayList(jsonFiles.size());
jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
Configuration config = new Configuration(new File("target"), "demo");
ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
reportBuilder.generateReports();
}
}
如您所见,我已将线程数设置为1,但即使我增加它,我也看不到执行时间的差异。
我不太确定并行运行是如何发生的。
有人能解释一下吗?
目前并行化的单位在特征文件级别。这意味着: