diff --git a/karate-core/src/main/java/com/intuit/karate/core/ScenarioRuntime.java b/karate-core/src/main/java/com/intuit/karate/core/ScenarioRuntime.java index 73a86e41a..abe4d6f7a 100644 --- a/karate-core/src/main/java/com/intuit/karate/core/ScenarioRuntime.java +++ b/karate-core/src/main/java/com/intuit/karate/core/ScenarioRuntime.java @@ -330,14 +330,14 @@ private static boolean isSelectedForExecution(FeatureRuntime fr, Scenario scenar return false; } String callTag = fr.featureCall.callTag; - if (callTag != null && (!fr.caller.isNone() || fr.perfHook != null)) { - // only if this is a legit "call" or a gatling "call by tag" + if (callTag != null) { if (tags.contains(callTag)) { logger.info("{} - call by tag at line {}: {}", fr, scenario.getLine(), callTag); return true; + } else { + logger.trace("skipping scenario at line: {} with call by tag effective: {}", scenario.getLine(), callTag); + return false; } - logger.trace("skipping scenario at line: {} with call by tag effective: {}", scenario.getLine(), callTag); - return false; } if (fr.caller.isNone()) { if (tags.evaluate(fr.suite.tagSelector, fr.suite.env)) { diff --git a/karate-core/src/test/java/com/intuit/karate/core/FeatureRuntimeTest.java b/karate-core/src/test/java/com/intuit/karate/core/FeatureRuntimeTest.java index a09eebd90..7da7aedbe 100644 --- a/karate-core/src/test/java/com/intuit/karate/core/FeatureRuntimeTest.java +++ b/karate-core/src/test/java/com/intuit/karate/core/FeatureRuntimeTest.java @@ -1,9 +1,6 @@ package com.intuit.karate.core; -import com.intuit.karate.Match; -import com.intuit.karate.Results; -import com.intuit.karate.Runner; -import com.intuit.karate.TestUtils; +import com.intuit.karate.*; import com.intuit.karate.report.Report; import com.intuit.karate.report.SuiteReports; import org.junit.jupiter.api.BeforeEach; @@ -406,4 +403,14 @@ void testConfigureNtlmAuthentication() { run("ntlm-authentication.feature"); } + @Test + void testSingleScenario() { + Feature feature = Feature.read("classpath:com/intuit/karate/core/single-scenario.feature"); + FeatureCall featureCall = new FeatureCall(feature, "@Scenario2", -1, null); + FeatureRuntime featureRuntime = FeatureRuntime.of(new Suite(), featureCall, null); + featureRuntime.run(); + + FeatureResult result = featureRuntime.result; + matchContains(result.getVariables(), "{ result2: 'Two' }"); + } } diff --git a/karate-core/src/test/java/com/intuit/karate/core/single-scenario.feature b/karate-core/src/test/java/com/intuit/karate/core/single-scenario.feature new file mode 100644 index 000000000..8a3604e37 --- /dev/null +++ b/karate-core/src/test/java/com/intuit/karate/core/single-scenario.feature @@ -0,0 +1,13 @@ +Feature: sample feature with distinct signature for each scenario + + @Scenario1 + Scenario: Set a Variable to "One" + * def result1 = 'One' + + @Scenario2 + Scenario: Set a Variable to "Two" + * def result2 = 'Two' + + @Scenario3 + Scenario: Set a Variable to "Three" + * def result3 = 'Three'