Maven test should use options = "--errors" by default (original) (raw)
Is your feature request related to a problem? Please describe.
By default, @MavenTest runs the forked Maven process without -e (or --errors). In case of an exception in the Mojo Under Test, this leads to woefully short mvn-stdout.log output:
[ERROR] Failed to execute goal org.example:example-maven-plugin:1.0.0:query (default) on project test: Execution default of goal org.example:example-maven-plugin:1.0.0:example failed. NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging
As stacktrace would often help already.
Describe the solution you'd like
Running a @MavenTest with --errors enabled seems the right choice. It's a test, after all.
Describe alternatives you've considered
Specifying MavenTest(options = "--errors") on every test is a workaround, but really cumbersome.
You could introduce your own JUnit 5 meta-annotation, however, but this would fix all annotation properties, not just options (the problem is that a single @MavenTest annotation is a bit coarse-grained), which is undesirable.
Additional context
If --errors is on by default, there is ATM no way to opt-out, as you cannot remove options via @MavenTest. I don't think this is a problem, however, as the behaviour of mojos AFAIK cannot be influenced by whether --error is on or off. Hence, there is no harm in it being always on.