allure-framework / allure-java

Allure integrations for Java test frameworks
Apache License 2.0
355 stars 225 forks source link

@Step doesn't work in Before/After #284

Closed dimkin-eu closed 5 years ago

dimkin-eu commented 5 years ago

I'm submitting a ...

What is the current behavior?

AllureLifecycle is failing in Before/After methods All attachments in steps also are lost ( because there are no Steps, your Cap :) )

07:59:26.911 [main] ERROR io.qameta.allure.AllureLifecycle - Could not add attachment: no test is running

07:59:26.912 [main] ERROR io.qameta.allure.AllureLifecycle - Could not update step: step with uuid c3cb22ea-18a5-4083-8cf3-79c0070997aa not found

07:59:26.912 [main] ERROR io.qameta.allure.AllureLifecycle - Could not stop step: step with uuid c3cb22ea-18a5-4083-8cf3-79c0070997aa not found

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

What is the expected behavior?

Steps added in Before/After methods

What is the motivation / use case for changing the behavior?

Make Allure moar great

Please tell us about your environment:

Allure version 2.8.1
Test framework testng@6.14.3
Allure integration allure-testng@2.8.1
Generate report using allure-maven@2.8.1

Other information

[//]: # ( . e.g. detailed explanation, stacktraces, related issues, suggestions . how to fix, links for us to have more context, eg. Stackoverflow, Gitter etc )

baev commented 5 years ago

@dimkin-eu added test for such case, can't reproduce the issue https://github.com/allure-framework/allure-java/pull/287

Could you please supply additional information?

dimkin-eu commented 5 years ago

@baev will try as a hint - it could be because of some steps are do in parallel

choojoykin commented 5 years ago

i have the same issue. Issue is reproduce on allure.testng 2.8.1 ver and not reproduce on 2.7.0 ver In my other projects i dont have this issue, cause i think didnt use extend some base test class in my test classes, where base test class contains @Before annotations ps i run single test @dimkin-eu did u use this artifact? `io.github.sskorol

test-data-supplier`
choojoykin commented 5 years ago

@baev use this example for reproduce issue `public class IssueTest {

@BeforeClass
private void checkForData() {
    beforeMethod();
}

@Step("Step before")
private void beforeMethod() {
    System.out.println("before");
}

@Step("Step in dp")
private Object createDpData() {
    System.out.println("dp step");
    return new Object();
}

@DataProvider(name = "dataprovider")
private Object[][] data() {
    List<Object[]> data = new ArrayList<>();
    Object p = createDpData();
    data.add(new Object[]{p});
    return data.toArray(new Object[data.size()][]);
}

@Test(dataProvider = "dataprovider")
public void test(final Object obj) {
    System.out.println("test");
}

}` u'll see this stdout

before 2018-12-24 16:36:30[ERROR] Could not start step: no test case running dp step 2018-12-24 16:36:30[ERROR] Could not update step: step with uuid 35e641d7-76cf-4d62-ad17-7811b21a89d4 not found 2018-12-24 16:36:30[ERROR] Could not stop step: step with uuid 35e641d7-76cf-4d62-ad17-7811b21a89d4 not found test

testNG 6.14.3 allure testNG 2.8.1 allure 2.7.0 allure maven 2.9.0

choojoykin commented 5 years ago

@dimkin-eu @baev trying to reproduce issue with junit 4.12 => `public class IssueTest {

@Test
@DisplayName("Not working")
public void test() {
    System.out.println("start");
    step();
    System.out.println("finish");
}

@Step("Step")
public void step() {
    System.out.println("step");
}

}`

1) If i run this test from maven test -Dtest=IssueTest => all good 2) If i run this test from intellijiIdea => i have errors from allure - test 2018-12-26 13:39:51[ERROR] Could not start step: no test case running step 2018-12-26 13:39:51[ERROR] Could not update step: step with uuid 8dad6a72-736d-48d5-9fae-3673eb822d85 not found 2018-12-26 13:39:51[ERROR] Could not stop step: step with uuid 8dad6a72-736d-48d5-9fae-3673eb822d85 not found done