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

🐞: No execution info when running tests via JUnit5 Launcher API

Open korpus95 opened this issue 6 months ago • 1 comments

What happened?

I run tests this way, but the results show an incomplete report, there is no data with annotations @Step and @Attachment

private static void executeTest(String testIdentifier) {
        LauncherDiscoveryRequest request;

        if (testIdentifier.contains("#")) {
            request = LauncherDiscoveryRequestBuilder.request()
                    .selectors(selectMethod(testIdentifier))
                    .build();
        } else {
            request = LauncherDiscoveryRequestBuilder.request()
                    .selectors(selectClass(testIdentifier))
                    .build();
        }
        System.setProperty("allure.results.directory", "target/test-result/allure-results");
        System.setProperty("junit.jupiter.extensions.autodetection.enabled", "true");

        LauncherConfig launcherConfig = LauncherConfig.builder()
                .enableTestExecutionListenerAutoRegistration(true)
                .build();

        SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();

        try (LauncherSession session = LauncherFactory.openSession(launcherConfig)) {
            Launcher launcher = session.getLauncher();
            launcher.registerTestExecutionListeners(summaryGeneratingListener);
            TestPlan testPlan = launcher.discover(request);
            launcher.execute(testPlan);
        }
    }

Can this be fixed?

What Allure Integration are you using?

allure-junit5

What version of Allure Integration you are using?

2.29.0

What version of Allure Report you are using?

2.29.0

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

korpus95 avatar Apr 05 '25 16:04 korpus95