Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(allure-karate): fix duplicate scenarios when call or callonce keywords are used #1144

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.'