🐞: [JUnit5] Test steps are not included in the report when creating custom fixtures in jUnit Extension.
LuroyJenkins opened this issue · 2 comments
LuroyJenkins commented
What happened?
When I create my prepare and teardown fixtures in beforeEach/afterEach in JUnit Extension, the steps of the test itself stop being visible.
My SampleExtension.java:
public class SampleExtension implements BeforeEachCallback, AfterEachCallback {
private String containerUuid;
@Override
public void beforeEach(ExtensionContext extensionContext) throws Exception {
String testResultUuid = Allure.getLifecycle()
.getCurrentTestCaseOrStep()
.orElseThrow(() -> new RuntimeException("Текущий тест или шаг не найден"));
containerUuid = UUID.randomUUID().toString();
TestResultContainer container = new TestResultContainer()
.setUuid(containerUuid)
.setName("Test Container for " + extensionContext.getDisplayName())
.setChildren(List.of(testResultUuid));
Allure.getLifecycle().startTestContainer(container);
String preparefixtureUuid = UUID.randomUUID().toString();
Allure.getLifecycle().startPrepareFixture(containerUuid, preparefixtureUuid, new FixtureResult()
.setName("Simulated BeforeEach")
.setStatus(Status.PASSED));
Allure.step("Before each extension step");
Allure.getLifecycle().stopFixture(preparefixtureUuid);
}
@Override
public void afterEach(ExtensionContext extensionContext) throws Exception {
String fixtureUuid = UUID.randomUUID().toString();
Allure.getLifecycle().startTearDownFixture(containerUuid, fixtureUuid, new FixtureResult()
.setName("Simulated AfterEach")
.setStatus(Status.PASSED));
Allure.step("After each extension step");
Allure.getLifecycle().stopFixture(fixtureUuid);
Allure.getLifecycle().stopTestContainer(containerUuid);
Allure.getLifecycle().writeTestContainer(containerUuid);
}
}
My StepTest.java:
@Test
public void lambdaStepTest() {
Allure.step("Step in test body");
}
If you add an BeforeEach annotation (from jUnit5), then everything will work.
What Allure Integration are you using?
allure-java-commons, allure-junit-platform, allure-junit5
What version of Allure Integration you are using?
2.26.0
What version of Allure Report you are using?
2.26.0
Code of Conduct
- I agree to follow this project's Code of Conduct
LuroyJenkins commented
It seems as if the problem is in the AllureThreadContext.
LuroyJenkins commented
Closing, not a defect.