Important to know with any solution: JUnit3 doesn't understand skipped.
There are several approaches:
- start every test with a condition: if ( !supportsCvs() ) { return; }
this makes the tests run when possible and won't fail when not
available. However, tests will be marked as successfully executed.
- Create a rule. It has been done for AbstractMojoTestCase[1], for
PlexusTestCase it should even be easier.
So instead of extending PlexusTestCase you'll add a JUnit rule and shift
the method calls.
Robert
[1]
https://github.com/apache/maven-plugin-testing/blob/master/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
On Tue, 05 Jun 2018 12:03:49 +0200, Basin Ilya <basini...@gmail.com> wrote:
Hi.
In Maven itself and its plugins there's a deep hierarchy of test classes
based on `PlexusTestCase`, which extends `junit.framework.TestCase`.
Although we've been using the `Junit4` library for a long time, the
actual tests are still public unannotated methods, starting with the
word "test".
The current approach is to mark ignored tests as succeeded. In
particular, when testing the `maven-scm-provider-cvsexe` project in the
absence of the `cvs` binary, it prints:
Running
org.apache.maven.scm.provider.cvslib.cvsexe.command.changelog.CvsExeChangeLogCommandTest
'cvs' is not a system command. Ignored testGetCommandWithBranchOrTag.
'cvs' is not a system command. Ignored
testGetCommandWithStartAndEndDate.
'cvs' is not a system command. Ignored testGetCommandWithoutEndDate.
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
This summary is undesired. It should have: `Skipped: 3`. As answered in
https://stackoverflow.com/questions/1689242/conditionally-ignoring-tests-in-junit-4
, we should use `org.junit.Assume` to conditionally skip tests, but this
doesn't work in unannotated Junit3-style test cases.
Removing TestCase from ancestors is barely an option, because our tests
actively use the methods inherited from it.
Annotating a particular class with `@RunWith(JUnit4.class)` will disable
all unannotated tests in this class and its descendants.
Is there a switch to make the JUnit4 runner run unannotated tests? Any
other ideas?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org