Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple system-out tags per testcase #593

Open
roded opened this issue Dec 24, 2023 · 2 comments
Open

Support multiple system-out tags per testcase #593

roded opened this issue Dec 24, 2023 · 2 comments

Comments

@roded
Copy link

roded commented Dec 24, 2023

What feature do you want to see added?

JUnit 5 can output multiple system-out (and system-err) tags per testcase tag.
It would be useful if the plugin would pick up the contents of all system-out tags as part of the testcase's stdout contents.

e.g.:
https://stackoverflow.com/questions/53822338/jenkins-not-displaying-test-case-stdout

Upstream changes

No response

Are you interested in contributing this feature?

No response

@timja
Copy link
Member

timja commented Dec 24, 2023

Do you have sample code of how this is generated in practice?

The stackoverflow post does have a reference output but it would be good to understand more about how it works.

@roded
Copy link
Author

roded commented Dec 25, 2023

I'm using something like this:

        LauncherDiscoveryRequestBuilder launcherDiscoveryRequestBuilder = LauncherDiscoveryRequestBuilder.request()
            .configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME, "true")
            .configurationParameter(LauncherConstants.CAPTURE_STDERR_PROPERTY_NAME, "true");
        for (String className : classNames) {
            launcherDiscoveryRequestBuilder.selectors(DiscoverySelectors.selectClass(className));
        }
        LauncherDiscoveryRequest launcherDiscoveryRequest = launcherDiscoveryRequestBuilder.build();

        PrintWriter printWriter = new PrintWriter(System.err);
        LegacyXmlReportGeneratingListener legacyXmlReportGeneratingListener = new LegacyXmlReportGeneratingListener(
            reportsDirectory.toPath(),
            printWriter);
        SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();
        LoggingListener loggingListener =
            LoggingListener.forBiConsumer((throwable, stringSupplier) -> logger.info(stringSupplier.get(), throwable));
        try (LauncherSession session = LauncherFactory.openSession()) {
            Launcher launcher = session.getLauncher();
            launcher.registerTestExecutionListeners(
                summaryGeneratingListener,
                legacyXmlReportGeneratingListener,
                loggingListener);
            TestPlan testPlan = launcher.discover(launcherDiscoveryRequest);
            logger.info("Executing test plan...");
            launcher.execute(testPlan);
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants