Skip to content

Commit

Permalink
Merge pull request #2505 from AKushWarrior/master
Browse files Browse the repository at this point in the history
Enable Calling Scenario By Tag
  • Loading branch information
ptrthomas authored Feb 13, 2024
2 parents 294e283 + e265b0a commit d654e1d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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' }");
}
}
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit d654e1d

Please sign in to comment.