THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- We use JUnit as the testing API for writing tests. We currently have a mix of JUnit 4 and JUnit 3 tests. Over time, we'd like to get the remainder of the JUnit 3 stuff migrated to the JUnit 4.
- Tests live with the module in the src/test/java directory. In general, the src/test/java directory would have the same package layout as the src/main/java. This allows the tests to test the package protected methods.
- We use Easymock as our mock framework for producing more complex unit tests.
- To run all the tests in a module, just run "mvn test" in the module.
- To run a single test in a module, run "mvn test -Dtest=MyTest" where MyTest is the name of the test class (no package specified) that you want to run.
...
There are generally two ways of running a test in a debugger.
- Within the IDE. If you setup eclipse properly, almost all the tests are runnable directly in eclipse. Right click on the test and select "Run As -> JUnit Test" (or "Debug As"). The test should just run.
- Externally via jpda. This is much harder. By default, mvn will fork the unit tests into a JVM that doesn't have JPDA enabled. However, it can be done. First, set your MAVEN_OPTS like:
Then you would need to run the test like "mvn test -Dtest=MyTest -Dsurefire.fork.mode=never". When mvn starts, you can attach your external debugger to it and assign breakpoints and such.Code Block export JPDA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" export MAVEN_OPTS="-XX:MaxPermSize=192m -Xmx512M $JPDA_OPTS"
...