开发者

Starting unit tests automatically after saving a file

开发者 https://www.devze.com 2023-03-12 19:01 出处:网络
With Ruby on Rails, I could use autotest, to run all my tests automatically each time, when I saved a file of my code. Additionally, the framework started only the tests that wer开发者_运维百科e affec

With Ruby on Rails, I could use autotest, to run all my tests automatically each time, when I saved a file of my code. Additionally, the framework started only the tests that wer开发者_运维百科e affected by the change and it notified me of the test results. Is there anything similar for my java development when using Eclipse?

I don't want something that generates tests for me, it just should start the right tests at the right time automatically.


Possibly Infinitest could interest you.


If you've got a maven-ish directory layout, you could use SBT (https://github.com/harrah/xsbt/) and run ~test in a terminal in the background. It doesn't (as far as I know) have autotest's ability to inteligently run a subset of tests, but other than that it's very similar in operation.


If you were using Maven, you could do this by changing the goals in Project -> Properties -> Maven -> Lifecycle Mappings.

You could probably do something similar with an Ant Builder.

However I don't think that the builders are able to figure out that a specific test needs to be run. Running all tests on each file save is liable to make Eclipse sluggish.


What I did in my Software Engineering class was to enable Eclipse to save automatically before each run. Then I had an ANT build Script which compiled and ran all the JUnit tests we had. It also generated the updated JavaDocs and JAR'd the whole program for us.

Here is the ANT main page and here is a nice tutorial to get you started.

0

精彩评论

暂无评论...
验证码 换一张
取 消