Run scala unit test from command line separately with Maven
Well, Maven is too good, when talking about speed. But I want something that is more acceptable. Imagine I wrote a test org.fun.AbcTestCase In such TestCase, I include some JUnit / TestNG tests Now I want to run only this test case, said org.fun.AbcTestCase from command line. How can I do that?
I know it's easy to do it within Eclipse or IDEA. However, I a开发者_StackOverflowm learning Scala and IDE support is currently terrible, especially when it comes to run unit test.
Here is why I find it difficult: The project would involve many dependencies. When I test my project as a Maven goal, surefire takes care of that. Mimic that with reasonable manual effort is important. The test process need to be fast enough with real time compiler (well, recompile the whole bunch of scala code is a terrible night mare).
Use the test parameter in the surefire:test mojo
mvn test -Dtest=MyTest
will run only the test MyTest.class, recompiling only if necessary (if changes are found).
If you are free to switch (as I imagine you might be if you have a toy project you're using to learn Scala) you might consider using SBT instead of Maven. Its IDE integration is only rudimentary, but it is quite handy for running tests (it can watch the source tree and re-run tests when you save, or even just the tests that failed during the last run.) Check out the website at http://simple-build-tool.googlecode.com/ .
精彩评论