Overview
When writing tests in Groovy, it's tempting to use def for the test methods, since that is typically the way to go in Groovy. However, for def the compiler produces a method that returns Object.
If this was a method annotated with @Test, it would be silently ignored by JUnit, as it should be a void method. This leads to lots of pulled hairs and other frustrations.
Test run finished after 13 ms
[ 2 containers found ]
[ 0 containers skipped ]
[ 2 containers started ]
[ 0 containers aborted ]
[ 2 containers successful ]
[ 0 containers failed ]
[ 0 tests found ]
[ 0 tests skipped ]
[ 0 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 0 tests failed ]
I would like JUnit to shout in my face that I'm using it wrong.
Overview
When writing tests in Groovy, it's tempting to use
deffor the test methods, since that is typically the way to go in Groovy. However, fordefthe compiler produces a method that returnsObject.If this was a method annotated with
@Test, it would be silently ignored by JUnit, as it should be avoidmethod. This leads to lots of pulled hairs and other frustrations.I would like JUnit to shout in my face that I'm using it wrong.