Skip to content

Commit

Permalink
fix(allure-karate): fix duplicate scenarios when call or callonce key…
Browse files Browse the repository at this point in the history
…words are used (fixes #1143, via #1144)
  • Loading branch information
umitozdemirf authored Nov 29, 2024
1 parent 547c624 commit af64da0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ public boolean beforeStep(final Step step,
return true;
}

if (step.getText().startsWith("call") || step.getText().startsWith("callonce")) {
return true;
}

final String uuid = parentUuid + "-" + step.getIndex();
final io.qameta.allure.model.StepResult stepResult = new io.qameta.allure.model.StepResult()
.setName(step.getText());
Expand All @@ -191,6 +195,10 @@ public void afterStep(final StepResult result,
}

final Step step = result.getStep();
if (step.getText().startsWith("call") || step.getText().startsWith("callonce")) {
return;
}

final String uuid = parentUuid + "-" + step.getIndex();

final Result stepResult = result.getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ void shouldCreateAttachments() {
.isGreaterThan(Long.parseLong(firstAttachmentDateCreated));
}

@Test
void shouldSkipCallAndCallOnceStepsInBeforeStep() {
final AllureResults results = runApi("classpath:testdata/call-callonce.feature");

assertThat(results.getTestResults())
.flatExtracting(TestResult::getSteps)
.extracting(StepResult::getName)
.doesNotContain("call", "callonce");
}

@Test
void buildTest() {
Runner.builder()
Expand Down
13 changes: 13 additions & 0 deletions allure-karate/src/test/resources/testdata/call-callonce.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: Call & Call once Feature
This feature calls another feature and demonstrates Allure reporting issue.

@smoke
Scenario: Main Scenario with a call
Given url 'https://jsonplaceholder.typicode.com'
When method GET
Then status 200

* call read('classpath:testdata/apiResponse.feature')
* callonce read('classpath:testdata/api.feature')

Then print 'Main scenario completed.'

0 comments on commit af64da0

Please sign in to comment.