Fail Tests on write to System.out
| Newsgroups | gmane.comp.java.junit.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, I am looking for a way to fail unittests when they write to System.out or System.err. I found different ways to achieve that and tried a solution with a RunListener, because these can be configured using the maven-surefire-plugin. Now I discovered, that RunListeners can't really fail tests because fail() throws an AssertionException and Exceptions remove the RunListener. Is there a better way to discover output? To summarize what I want: * a way to discover output via System.out without preventing Logger functionality * this way should not involve huge code changes on the testclasses ( like adding TestRules everywhere) * all unittests which produced output should be reported as "failing" when you run with `mvn test` I tried to answer these questions on SO but got only a few helpful responses, so I thought I ask the specialists here and get more opinions. For reference the SO questions: * http://stackoverflow.com/questions/33214683 * http://stackoverflow.com/questions/33207996 Any help on this topic is very appreciated. Regards Andreas Worm ------------------------------------ Posted by: Andreas Worm <[email protected]> ------------------------------------