How to get a test resource file?

Probably just useful if you have the file available, for example when doing unit tests – this will not load it out of a jar AFAIK. URL url = Thread.currentThread().getContextClassLoader().getResource(“mypackage/YourFile.csv”); File file = new File(url.getPath()); // where the file is in the classpath eg. <project>/src/test/resources/mypackage/YourFile.csv

JUnit tests pass in Eclipse but fail in Maven Surefire

I had the same problem (JUnit tests failed in Maven Surefire but passed in Eclipse) and managed to solve it by setting forkMode to always in the maven surefire configuration in pom.xml: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> <configuration> <forkMode>always</forkMode> </configuration> </plugin> Surefire parameters: http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html Edit (January 2014): As Peter Perháč pointed out, the forkMode parameter is … Read more

How do I get my Maven Integration tests to run

The Maven build lifecycle now includes the “integration-test” phase for running integration tests, which are run separately from the unit tests run during the “test” phase. It runs after “package”, so if you run “mvn verify”, “mvn install”, or “mvn deploy”, integration tests will be run along the way. By default, integration-test runs test classes … Read more