空手道。具有多个标签和功能的跑步者执行

问题描述 投票:0回答:1

我正在尝试运行具有多个标签和功能的空手道套件,但没有任何功能场景被执行。下面是代码:

import com.dell.karate.ReportportalHook;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import com.intuit.karate.RunnerOptions;

class TestRunnerParallel {

@Test
void testParallel() throws IOException {

    List<String> tags = new ArrayList<String>();
    tags.add("@test1");
    tags.add("@test2");
    List<String> features = new ArrayList<String>();
    features.add("testSuite1");

    RunnerOptions options = RunnerOptions.fromAnnotationAndSystemProperties(features, tags, getClass());
    Results results = Runner.parallel(options.getTags(),
            options.getFeatures(),
            options.getName(),
            Collections.singletonList(new ReportportalHook()),
            1,
            null);
}

}

但是当只有一个标签时,如下面的代码,它执行得很好。注意:当我每次执行一个标签时,它工作正常。我不确定问题是什么?

import com.dell.karate.ReportportalHook;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import com.intuit.karate.RunnerOptions;

class TestRunnerParallel {

@Test
void testParallel() throws IOException {

    List<String> tags = new ArrayList<String>();
    tags.add("@test1");
    List<String>  features = null;

    RunnerOptions options = RunnerOptions.fromAnnotationAndSystemProperties(features, tags, getClass());
    Results results = Runner.parallel(options.getTags(),
            options.getFeatures(),
            options.getName(),
            Collections.singletonList(new ReportportalHook()),
            1,
            null);
}

}

karate
1个回答
0
投票

标签1.功能

Feature: Test Feature1

  @run_first
  Scenario: Scenario1
    * print 'Scenario1'

  @run_second
  Scenario: Scenario2
    * print 'Scenario2'

标签2.功能

Feature: Test Feature2

  @run_third
  Scenario: Scenario3
  * print 'Scenario3'

TagTestParallel.java

public class TagTestParallel {

    @Test
    void testParallel() {
        Results results = Runner.path("classpath:com/tests/")
                  .tags("@run_second,@run_third")
                .parallel(0);
        assertEquals(0, results.getFailCount(), results.getErrorMessages());
    }
}

enter image description here

我在 src/test/java 下的 com.tests 包中添加了 Tag1.feature 和 Tag2.feature。这应该有效。我希望这就是您正在寻找的。

© www.soinside.com 2019 - 2024. All rights reserved.