简体   繁体   English

Cucumber Runner 不会使用空手道加载所有功能文件

[英]Cucumber Runner doesn't load all feature files using Karate

I'm using Karate for testing REST API, now I'm trying to run feature files in parallel:我正在使用 Karate 来测试 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");
   }
}

The test runs only 3 feature files in parallel and doesn't run all 5 features.该测试仅并行运行 3 个功能文件,并没有运行所有 5 个功能。 I got this code from CucumberRunner.parallel function:我从 CucumberRunner.parallel 函数中得到了这个代码:

CucumberRunner runner = new CucumberRunner(this.getClass());
List<FeatureFile> featureFiles = runner.getFeatureFiles();

Then tried to load my feature files, the list size is 3, that means the function didn't load all features.然后尝试加载我的功能文件,列表大小为 3,这意味着该功能没有加载所有功能。 Any idea why this is happening?知道为什么会这样吗?

Note: all feature files under the same package.注意:同一个包下的所有功能文件。

Parallel() function code: 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);
    }
}

Thanks :)谢谢 :)

The simplest explanation is that the tags in the @CucumberOptions is having an effect.最简单的解释是@CucumberOptions中的tags正在起作用。 Try commenting it out and try again.尝试将其注释掉,然后重试。 Else there is nothing I can make out from the information you have provided.否则,我无法从您提供的信息中看出任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Maven不会执行黄瓜功能文件 - Cucumber feature files are not executed using Maven 是否可以为由多个Runner类运行的多个功能文件创建一个Cucumber报表? - Any way to create one single Cucumber report for multiple feature files run by as many Runner classes? 我正在尝试在我的 Cucumber 跑步者中使用标签,但不起作用。 我是 Cucumber 的新手 - I am trying use tag in my Cucumber runner but doesn't work. I am new to Cucumber 无法使用 TestNG 测试运行器运行单个 Cucumber 场景 - Can't run individual Cucumber scenarios using TestNG test runner 如何使用Cucumber runner加载Spring应用程序上下文 - How to load Spring application context with Cucumber runner Cucumber Runner 类抛出不安全的 http url TestNGException,但是我的 .feature 文件和 testng.xml 将运行该套件而不会出现问题 - Cucumber Runner class throws unsecured http url TestNGException, however my .feature files and testng.xml will run the suite without issues 如何排除黄瓜功能文件 - How to exclude Cucumber feature files 执行多个黄瓜功能文件 - execute multiple cucumber feature files 空手道中如何执行其他目录特征文件 - How to execute other directory feature files in karate 在IDE中运行.feature文件不会读取cumberner类 - Running the .feature file within the IDE does not read the cucumber runner class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM