Differences between Runining Unit Test in Eclipse and in Maven
In Eclipse you can run JUnit Tests by selecting any folder that contains unit tests (e.g., uimaj-core/src/main/tests), right-clicking, and selecting Run As -> JUnit Test. However, it is important to realize that there are some differences between running the tests in Eclipse and running them on the Maven command line.
In Maven, test cases are not allowed to access test classes or resources from other projects. For example, classes in uimaj-cpe/src/test/java cannot refer to classes in uimaj-core/src/test/java, nor can they refer to resources in uimaj-core/src/test/resources.
Eclipse does not enforce this restriction. In Eclipse, uimaj-cpe has a project dependency on uimaj-core, and so everything in uimaj-core is visible to everything in uimaj-cpe. Eclipse doesn't distinguish between code in src/main and code in src/test in the way that Maven does.
Another difference is that Maven does not allow resource (non-java) files under src/test/java (or src/main/java for that matter). They must be under src/test/resources (src/main/resources, respectively). Eclipse does not enforce this restriction.
Because of these differences it is possible to create Unit tests that run in Eclipse but fail when run from the Maven command line. To guard against this, please always run the unit tests in Maven before committing changes. This is done by executing mvn install
from the uimaj
directory.
In Maven only test classes that ends with "Test" are executed. If the test classes ends for example with "Tests" or with anything else they are not executed.