Skip to content

Commit 0dcd87b

Browse files
authored
fix(cucumberjvm): fix Runtime API (fixes #1008, fixes #1006, via #1011)
1 parent 4434129 commit 0dcd87b

File tree

20 files changed

+1859
-988
lines changed

20 files changed

+1859
-988
lines changed

allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java

Lines changed: 271 additions & 195 deletions
Large diffs are not rendered by default.

allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/AllureCucumber4JvmTest.java

Lines changed: 151 additions & 82 deletions
Large diffs are not rendered by default.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright 2016-2024 Qameta Software Inc
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.qameta.allure.cucumber4jvm.samples;
17+
18+
import io.cucumber.java.Before;
19+
import io.cucumber.java.en.And;
20+
import io.cucumber.java.en.Then;
21+
import io.cucumber.java.en.When;
22+
import io.qameta.allure.Allure;
23+
24+
/**
25+
* @author charlie (Dmitry Baev).
26+
*/
27+
public class RuntimeApiSteps {
28+
29+
@Before("@beforeScenario")
30+
public void beforeScenario(){
31+
// nothing
32+
}
33+
34+
@Before("@beforeFeature")
35+
public void beforeFeature(){
36+
// nothing
37+
}
38+
39+
@When("^step 1$")
40+
public void step1() {
41+
Allure.step("step1 nested");
42+
Allure.link("step1", "https://example.org/step1");
43+
Allure.getLifecycle().getCurrentTestCase().ifPresent(uuid -> {
44+
System.out.println("step1: " + uuid);
45+
});
46+
}
47+
48+
@When("^step 2$")
49+
public void step2() {
50+
Allure.step("step2 nested");
51+
Allure.link("step2", "https://example.org/step2");
52+
Allure.getLifecycle().getCurrentTestCase().ifPresent(uuid -> {
53+
System.out.println("step2: " + uuid);
54+
});
55+
}
56+
57+
@And("^step 3$")
58+
public void step3() {
59+
Allure.step("step3 nested");
60+
Allure.link("step3", "https://example.org/step3");
61+
Allure.getLifecycle().getCurrentTestCase().ifPresent(uuid -> {
62+
System.out.println("step3: " + uuid);
63+
});
64+
}
65+
66+
@Then("^step 4$")
67+
public void step4() {
68+
Allure.step("step4 nested");
69+
Allure.link("step4", "https://example.org/step4");
70+
Allure.getLifecycle().getCurrentTestCase().ifPresent(uuid -> {
71+
System.out.println("step4: " + uuid);
72+
});
73+
}
74+
75+
@And("^step 5$")
76+
public void step5() {
77+
Allure.step("step5 nested");
78+
Allure.link("step5", "https://example.org/step5");
79+
Allure.getLifecycle().getCurrentTestCase().ifPresent(uuid -> {
80+
System.out.println("step5: " + uuid);
81+
});
82+
}
83+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@beforeFeature
2+
Feature: Should support runtime API in all steps
3+
4+
@beforeScenario
5+
Scenario: Scenario with Runtime API usage
6+
When step 1
7+
When step 2
8+
And step 3
9+
Then step 4
10+
And step 5

allure-cucumber5-jvm/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ dependencies {
1515
testImplementation("org.assertj:assertj-core")
1616
testImplementation("org.junit.jupiter:junit-jupiter-api")
1717
testImplementation("org.slf4j:slf4j-simple")
18+
testImplementation(project(":allure-assertj"))
1819
testImplementation(project(":allure-java-commons-test"))
20+
testImplementation(project(":allure-junit-platform"))
1921
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
2022
}
2123

0 commit comments

Comments
 (0)