From af64da0f016cb9fb48c5c7bb2bff0be990301bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20=C3=96zdemir?= <38186111+umitozdemirf@users.noreply.github.com> Date: Fri, 29 Nov 2024 13:32:19 +0300 Subject: [PATCH] =?UTF-8?q?fix(allure-karate):=20fix=20duplicate=20scenari?= =?UTF-8?q?os=20when=20call=20or=20callonce=20keywords=20are=20used=20(fix?= =?UTF-8?q?es=C2=A0#1143,=20via=20#1144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/qameta/allure/karate/AllureKarate.java | 8 ++++++++ .../io/qameta/allure/karate/AllureKarateTest.java | 10 ++++++++++ .../test/resources/testdata/call-callonce.feature | 13 +++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 allure-karate/src/test/resources/testdata/call-callonce.feature diff --git a/allure-karate/src/main/java/io/qameta/allure/karate/AllureKarate.java b/allure-karate/src/main/java/io/qameta/allure/karate/AllureKarate.java index 2c629a9f2..6fa4e1cb8 100644 --- a/allure-karate/src/main/java/io/qameta/allure/karate/AllureKarate.java +++ b/allure-karate/src/main/java/io/qameta/allure/karate/AllureKarate.java @@ -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()); @@ -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(); diff --git a/allure-karate/src/test/java/io/qameta/allure/karate/AllureKarateTest.java b/allure-karate/src/test/java/io/qameta/allure/karate/AllureKarateTest.java index a1cf77b39..fedbd276f 100644 --- a/allure-karate/src/test/java/io/qameta/allure/karate/AllureKarateTest.java +++ b/allure-karate/src/test/java/io/qameta/allure/karate/AllureKarateTest.java @@ -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() diff --git a/allure-karate/src/test/resources/testdata/call-callonce.feature b/allure-karate/src/test/resources/testdata/call-callonce.feature new file mode 100644 index 000000000..e64bbf049 --- /dev/null +++ b/allure-karate/src/test/resources/testdata/call-callonce.feature @@ -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.'