Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 黄瓜赛跑者';t使用空手道加载所有要素文件_Java_Cucumber_Karma Runner_Cucumber Java_Karate - Fatal编程技术网

Java 黄瓜赛跑者';t使用空手道加载所有要素文件

Java 黄瓜赛跑者';t使用空手道加载所有要素文件,java,cucumber,karma-runner,cucumber-java,karate,Java,Cucumber,Karma Runner,Cucumber Java,Karate,我正在使用空手道测试REST API,现在我正在尝试并行运行功能文件: @CucumberOptions(tags = { "@someTest" }) public class ParallelTest { @Test public void testParallel() { KarateStats stats = CucumberRunner.parallel(getClass(), 5, "target/surefire-reports/cucumber-html-re

我正在使用空手道测试REST API,现在我正在尝试并行运行功能文件:

@CucumberOptions(tags = { "@someTest" })
public class ParallelTest {

@Test
public void testParallel() {
    KarateStats stats = CucumberRunner.parallel(getClass(), 5, 
    "target/surefire-reports/cucumber-html-reports");
    Assert.assertTrue(stats.getFailCount() == 0, "scenarios failed");
   }
}
该测试仅并行运行3个功能文件,而不是运行所有5个功能。 我从CucumberRunner.parallel函数获得了以下代码:

CucumberRunner runner = new CucumberRunner(this.getClass());
List<FeatureFile> featureFiles = runner.getFeatureFiles();
CucumberRunner=新的CucumberRunner(this.getClass());
List featureFiles=runner.getFeatureFiles();
然后尝试加载我的功能文件,列表大小为3,这意味着函数没有加载所有功能。 知道为什么会这样吗

注意:同一软件包下的所有要素文件

Parallel()函数代码:

  public static KarateStats parallel(Class clazz, int threadCount, String reportDir) {
    KarateStats stats = KarateStats.startTimer();
    ExecutorService executor = Executors.newFixedThreadPool(threadCount);
    CucumberRunner runner = new CucumberRunner(clazz);
    List<FeatureFile> featureFiles = runner.getFeatureFiles();
    List<Callable<KarateJunitFormatter>> callables = new ArrayList<>(featureFiles.size());
    int count = featureFiles.size();
    for (int i = 0; i < count; i++) {
        int index = i + 1;
        FeatureFile featureFile = featureFiles.get(i);
        callables.add(() -> {
            String threadName = Thread.currentThread().getName();
            KarateJunitFormatter formatter = getFormatter(reportDir, featureFile);
            logger.info(">>>> feature {} of {} on thread {}: {}", index, count, threadName, featureFile.feature.getPath());
            runner.run(featureFile, formatter);
            logger.info("<<<< feature {} of {} on thread {}: {}", index, count, threadName, featureFile.feature.getPath());
            formatter.done();
            return formatter;
        });
    }
    try {
        List<Future<KarateJunitFormatter>> futures = executor.invokeAll(callables);
        stats.stopTimer();
        for (Future<KarateJunitFormatter> future : futures) {
            KarateJunitFormatter formatter = future.get();
            stats.addToTestCount(formatter.getTestCount());
            stats.addToFailCount(formatter.getFailCount());
            stats.addToSkipCount(formatter.getSkipCount());
            stats.addToTimeTaken(formatter.getTimeTaken());
            if (formatter.isFail()) {
                stats.addToFailedList(formatter.getFeaturePath());
            }
        }
        stats.printStats(threadCount);
        return stats;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
publicstatickaratestatts并行(类clazz,int-threadCount,stringreportdir){
KarateStats stats=KarateStats.startTimer();
ExecutorService executor=Executors.newFixedThreadPool(线程计数);
黄瓜跑步者=新黄瓜跑步者(clazz);
List featureFiles=runner.getFeatureFiles();
List callables=newarraylist(featureFiles.size());
int count=featureFiles.size();
for(int i=0;i{
字符串threadName=Thread.currentThread().getName();
KarateJunitFormatter formatter=getFormatter(reportDir,featureFile);
logger.info(“>>>>线程{}:{}上{}的{}特征{}”,索引,计数,线程名,特征文件.feature.getPath());
runner.run(featureFile,格式化程序);

logger.info("最简单的解释是
@CucumberOptions
中的
标签正在发挥作用。请尝试对其进行注释,然后再试一次。否则,从您提供的信息中,我看不出任何东西。

嗨,彼得,感谢您提供的神奇工具和您的回复。我删除并重新创建了所有5个功能文件,这是我最喜欢的解决我的问题!@NaelAbdeljawad great:)通常情况下,这不应该发生,所以请确保您的maven pom.xml具有文档中提到的调整,以防您将功能文件保存在
src/test/java
等中(如果有帮助,请进行升级/将答案标记为已接受)