Skip to content

Commit d654e1d

Browse files
authored
Merge pull request #2505 from AKushWarrior/master
Enable Calling Scenario By Tag
2 parents 294e283 + e265b0a commit d654e1d

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

karate-core/src/main/java/com/intuit/karate/core/ScenarioRuntime.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,14 @@ private static boolean isSelectedForExecution(FeatureRuntime fr, Scenario scenar
330330
return false;
331331
}
332332
String callTag = fr.featureCall.callTag;
333-
if (callTag != null && (!fr.caller.isNone() || fr.perfHook != null)) {
334-
// only if this is a legit "call" or a gatling "call by tag"
333+
if (callTag != null) {
335334
if (tags.contains(callTag)) {
336335
logger.info("{} - call by tag at line {}: {}", fr, scenario.getLine(), callTag);
337336
return true;
337+
} else {
338+
logger.trace("skipping scenario at line: {} with call by tag effective: {}", scenario.getLine(), callTag);
339+
return false;
338340
}
339-
logger.trace("skipping scenario at line: {} with call by tag effective: {}", scenario.getLine(), callTag);
340-
return false;
341341
}
342342
if (fr.caller.isNone()) {
343343
if (tags.evaluate(fr.suite.tagSelector, fr.suite.env)) {

karate-core/src/test/java/com/intuit/karate/core/FeatureRuntimeTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.intuit.karate.core;
22

3-
import com.intuit.karate.Match;
4-
import com.intuit.karate.Results;
5-
import com.intuit.karate.Runner;
6-
import com.intuit.karate.TestUtils;
3+
import com.intuit.karate.*;
74
import com.intuit.karate.report.Report;
85
import com.intuit.karate.report.SuiteReports;
96
import org.junit.jupiter.api.BeforeEach;
@@ -406,4 +403,14 @@ void testConfigureNtlmAuthentication() {
406403
run("ntlm-authentication.feature");
407404
}
408405

406+
@Test
407+
void testSingleScenario() {
408+
Feature feature = Feature.read("classpath:com/intuit/karate/core/single-scenario.feature");
409+
FeatureCall featureCall = new FeatureCall(feature, "@Scenario2", -1, null);
410+
FeatureRuntime featureRuntime = FeatureRuntime.of(new Suite(), featureCall, null);
411+
featureRuntime.run();
412+
413+
FeatureResult result = featureRuntime.result;
414+
matchContains(result.getVariables(), "{ result2: 'Two' }");
415+
}
409416
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature: sample feature with distinct signature for each scenario
2+
3+
@Scenario1
4+
Scenario: Set a Variable to "One"
5+
* def result1 = 'One'
6+
7+
@Scenario2
8+
Scenario: Set a Variable to "Two"
9+
* def result2 = 'Two'
10+
11+
@Scenario3
12+
Scenario: Set a Variable to "Three"
13+
* def result3 = 'Three'

0 commit comments

Comments
 (0)