Junit5: Vintage 5.1.0-RC1 executes @BeforeClass before [runner:VintageBeforeClass$VintageTest] event

Created on 6 Feb 2018  路  5Comments  路  Source: junit-team/junit5

Overview

This is a bug report. Different behaviors are observed after upgrading to 5.1.0-RC1:

public class VintageBeforeClass {
    public static void main(String[] args) {
        Launcher launcher = LauncherFactory.create();

        launcher.registerTestExecutionListeners(new TestExecutionListener() {
            @Override
            public void executionStarted(TestIdentifier testIdentifier) {
                System.out.println("Start: " + testIdentifier.getUniqueId());
            }
        });

        LauncherDiscoveryRequestBuilder requestBuilder = LauncherDiscoveryRequestBuilder.request()
                .selectors(selectClass(VintageTest.class));
        launcher.execute(requestBuilder.build());
    }

    public static class VintageTest {
        @BeforeClass
        public static void beforeClass() {
            System.out.println("before class!");
        }

        @org.junit.Test
        public void test() {
            System.out.println("test!");
        }
    }
}

With org.junit.vintage:junit-vintage-engine:5.1.0-M2:

Start: [engine:junit-vintage]
Start: [engine:junit-vintage]/[runner:VintageBeforeClass$VintageTest]
before class!
Start: [engine:junit-vintage]/[runner:VintageBeforeClass$VintageTest]/[test:test(VintageBeforeClass$VintageTest)]
test!

With org.junit.vintage:junit-vintage-engine:5.1.0-RC1:

Start: [engine:junit-vintage]
before class!
Start: [engine:junit-vintage]/[runner:VintageBeforeClass$VintageTest]
Start: [engine:junit-vintage]/[runner:VintageBeforeClass$VintageTest]/[test:test(VintageBeforeClass$VintageTest)]
test!

5.1.0-RC1 executes the @BeforeClass method before the [runner:VintageBeforeClass$VintageTest] event is triggered. This makes us unable to track which class the stdout comes from.

Vintage execution bug

Most helpful comment

Thanks for reporting this issue! I know what I've done to cause this. I'll fix it ASAP.

All 5 comments

Thanks for reporting this issue! I know what I've done to cause this. I'll fix it ASAP.

When this is fixed on master, you may refer to our snapshot builds at https://oss.sonatype.org/content/repositories/snapshots for re-testing, @blindpirate.

Thanks! @sormuras @marcphilipp

@blindpirate

FYI: @marcphilipp fixed the bug in a0a4d6dbbb0e2e1b5066c93a3fd0ce59c688ca3f.

So you should be able to try out the fix in the next snapshot.

Sounds great, thanks! @sbrannen

Was this page helpful?
0 / 5 - 0 ratings