I'm looking at porting an old junit4 extension to junit5 by creating an extension. One feature that I'm thus far failing on is to fail any test method that writes on System.out or System.err, and have the failure point to that specific test.
I tried using TestExecutionListener#reportingEntryPublished together with junit.jupiter.extensions.autodetection.enabled=true, and I get to that method, but it is AFAICT too late to actually change the status of the test to FAILED at this point. Or can I?
I started playing with BeforeAllCallback and AfterAllCallback and do redirects of out/err and assert on a string buffer instead. I could possibly be able to get that to work, but that seems like something that I would be likely to screw up and and up finding bugs years from now :) Our runner for junit4 does something like this, but it is really overcomplicated and I wouldn't wish it on anyone to try to maintain something similar.
Any way to do this nicely in junit5?