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

Add options to print stack trace / stdout / stderr on error or failure #39

Merged
merged 4 commits into from
May 13, 2023

Conversation

blutorange
Copy link
Contributor

@blutorange blutorange commented May 7, 2023

I just found this extension and it is great! Makes test output much more readable. One thing I did miss, however, is the ability to see console output and stack traces when a test fails. This commit

  • adds some options to print the strack trace and stdout / stderr depending on whether a test fails or succeeds
  • also adds a <theme>ASCII</code> or <theme>UNICODE</theme> option and deprecates JUnit5StatelessTestsetInfoTreeReporterUnicode in favor of that option. If we have multiple options, the theme might as well be an option as well.

From the readme:

By default, <consoleOutputReporter><disable>true</disable></consoleOutputReporter> disables all console output. To debug test failures, it may be useful to see the console output and stack traces when a test fails. To do so, you can configure this extension like this:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M7</version>
    <dependencies>
        <dependency>
            <groupId>me.fabriciorby</groupId>
            <artifactId>maven-surefire-junit5-tree-reporter</artifactId>
            <version>1.1.0</version>
        </dependency>
    </dependencies>
    <configuration>
        <reportFormat>plain</reportFormat>
        <consoleOutputReporter>
            <disable>true</disable>
        </consoleOutputReporter>
        <statelessTestsetInfoReporter
                implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
            <printStacktrackeOnError>true</printStacktrackeOnError>
            <printStacktrackeOnFailure>true</printStacktrackeOnFailure>
            <printStdoutOnError>true</printStdoutOnError>
            <printStdoutOnFailure>true</printStdoutOnFailure>
            <printStdoutOnSuccess>false</printStdoutOnSuccess>
            <printStderrOnError>true</printStderrOnError>
            <printStderrOnFailure>true</printStderrOnFailure>
            <printStderrOnSuccess>false</printStderrOnSuccess>
            <theme>UNICODE</theme>
        </statelessTestsetInfoReporter>
    </configuration>
</plugin>

The options all default to false to preserve the current behavior. Although I think it would also help to print details for errors and failures by default.

The resulting output looks like this:

image

image

@fabriciorby fabriciorby self-requested a review May 13, 2023 19:06
@fabriciorby
Copy link
Owner

Hey! Really nice PR, thanks for that! I didn't know it was possible to get params from the XML like that! :)

I will merge to the develop branch for now, do some minor changes, and then we go master.

@fabriciorby fabriciorby changed the base branch from master to develop May 13, 2023 20:17
@fabriciorby fabriciorby merged commit 86e519b into fabriciorby:develop May 13, 2023
@blutorange
Copy link
Contributor Author

If I can help, let me know. This plugin is really useful, we've got integration tests that produce huge amounts of logging output. The log files from the CI run are now only a few MB instead of several dozen MB : )

fabriciorby added a commit that referenced this pull request May 13, 2023
* Fixed #30 - Upgrade to maven-surefire-plugin:3.0.0-M8 (#31)

* Fixed #32 - Using JUnit Jupiter BOM 5.9.2 (#33)

* Fixed #34 - Using mockito-bom 4.11.0 (#35)

* Add options to print stack trace / stdout / stderr on error or failure (#39)

* Update README, pom.xml and make it Java 8 compatible (#41)

---------

Co-authored-by: Karl Heinz Marbaise <[email protected]>
Co-authored-by: Andre Wachsmuth <[email protected]>
Co-authored-by: Andre Wachsmuth <[email protected]>
fabriciorby added a commit that referenced this pull request May 13, 2023
* Fixed #30 - Upgrade to maven-surefire-plugin:3.0.0-M8 (#31)

* Fixed #32 - Using JUnit Jupiter BOM 5.9.2 (#33)

* Fixed #34 - Using mockito-bom 4.11.0 (#35)

* Add options to print stack trace / stdout / stderr on error or failure (#39)

* Update README, pom.xml and make it Java 8 compatible (#41)

---------

Co-authored-by: Karl Heinz Marbaise <[email protected]>
Co-authored-by: Andre Wachsmuth <[email protected]>
Co-authored-by: Andre Wachsmuth <[email protected]>
fabriciorby added a commit that referenced this pull request May 13, 2023
* Fixed #30 - Upgrade to maven-surefire-plugin:3.0.0-M8 (#31)

* Fixed #32 - Using JUnit Jupiter BOM 5.9.2 (#33)

* Fixed #34 - Using mockito-bom 4.11.0 (#35)

* Add options to print stack trace / stdout / stderr on error or failure (#39)

* Update README, pom.xml and make it Java 8 compatible (#41)

---------

Co-authored-by: Karl Heinz Marbaise <[email protected]>
Co-authored-by: Andre Wachsmuth <[email protected]>
Co-authored-by: Andre Wachsmuth <[email protected]>
@fabriciorby
Copy link
Owner

If I can help, let me know. This plugin is really useful, we've got integration tests that produce huge amounts of logging output. The log files from the CI run are now only a few MB instead of several dozen MB : )

I have just deployed the new version 1.2.0. :)

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

Successfully merging this pull request may close these issues.

3 participants