allure-java icon indicating copy to clipboard operation
allure-java copied to clipboard

Allure does not create any results when @BeforeClass fails

Open OlegKuzovkov opened this issue 3 years ago • 3 comments

Describe the bug We have a test class with @BeforeClass setup. If it fails, no allure-results folder is created with any test results. When you use @Before method, all test cases in the class are marked as failed as expected.

To Reproduce Steps to reproduce the behavior:

import lombok.extern.log4j.Log4j2;
import org.junit.BeforeClass;
import org.junit.Test;


@Log4j2
public class BeforeCassTest {

    @BeforeClass
    public static void before(){
        log.info("failing in before");
        assert false;
    }

    @Test
    public void test1() {
        log.info("passing in test");
        assert true;
    }
}

Expected behavior allure-results folder should be generated with a test1 marked as failed

Environment allure-junit4 = 2.17.3 junit = 4.13.2

OlegKuzovkov avatar Aug 29 '22 13:08 OlegKuzovkov

@OlegKuzovkov Hi Oleg, could you please attach JUnit4 test results files generated after running of such a test? thanks

cheshi-mantu avatar Sep 02 '22 05:09 cheshi-mantu

There you go: Test Results - BeforeCassTest.zip

OlegKuzovkov avatar Sep 04 '22 12:09 OlegKuzovkov

Hi folks, similar case happens with TestNG. I have several cases where @BeforeClass initializes connections which might fail, and therefore are not reported.

Please, let me know if we should combine implementation/fix or in separate issues.

I'd be happy to help to fix/implement if I can have proper upport.

vinipx avatar Sep 30 '22 23:09 vinipx

@vinipx please report this for TestNG separately. We won't fix this for JUnit4, we recommend moving the project to JUnit5. There will be too much work to fix the behaviour of the framework by means of the integratoin.

cheshi-mantu avatar Nov 01 '22 13:11 cheshi-mantu