I want to run my unit tests automatically when I save my Eclipse project. The project is built automatically whenever I save a file, so I think this should be possible in some way.
How do I do it? Is the only option really to get an ant script and change the project build to use the ant script with targets build and compile?
Update I will try 2 different approaches now:
JUnit provides Test runners for running tests. JUnit tests can be run automatically and they check their own results and provide immediate feedback.
In Eclipse, you create a JUnit test case by selecting in the main window menubar File -> New -> JUnit Test Case. Once you clicked on the item, a big dialog should pop out. In the pop up you can choose the JUnit version (4 is the one we use) and the package and class name of your test case.
For sure it it unwise to run all tests, because we can have for example 20.000 tests whereas our change could affect only, let's say 50 of them, among which are tests for the class we have changed and tests for classes that collaborate with our class.
There is an unseful plugin called infinitetest http://improvingworks.com/products/infinitest/ which runs only some tests ( related to class we've changed ) just after we save changes. It also integrate quite nicely with editor ( using annotations ) and problem view - displaying not-passing tests like errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With