Is it possible to run incremental/automated JUnit testing in Eclipse?
Asked Answered
C

3

8

Eclipse support incremental compiling. If I save a source file then it will compile the modified files.

Is it possible after such incremental compile also to run the JUnit tests of the same package and show the fail in the error view. Then I can see the JUnit test failing and compiling errors in the same view without extra action. Are there any plugins that can do it?

Conspire answered 30/1, 2011 at 9:1 Comment(2)
I think that you would quickly find that such a feature was annoying and / or slowed you down.Sustenance
It should only run the test of the saved class. If the unit tests run longer as the compiler then it are not unit tests else functional tests. You should split unit and functional tests.Conspire
A
9

You have to look at these plugins:

  • JUnit Max: Not free, developed by Kent Benk (one of the men behind the TDD practice);
  • MoreUnit: Free, but essentially dedicated to help you write the tests;
  • Infinitest: Now free, this plugin is dedicated to run the tests related to the files you have just modified.

So regarding your needs, I suggest that you install MoreUnit and Infinitest plugins.

Augean answered 30/1, 2011 at 9:53 Comment(2)
Last time I checked, Infinitest was free but only for noncommercial use. Looks like now it's just 100% totally free. Good to know, thanks!Juju
@MatrixFrog Yes, indeed. Some of my ex-colleagues (who now works for algodeal - beta.algodeal.com) are now working on this plugin, and make it free, hosted on GitHub.Augean
C
2

Use ExternalToolBuilder.

It can be triggered by source modify.

There’s Eclipse customized feature(integrate external tool builder) which may meet your need. But it needs extra effort to write the scripts I never used. Automatic test cases is not a convenient way, at least single click to see green bar in Eclipse is enough for me:)

Cockscomb answered 30/1, 2011 at 9:29 Comment(2)
We have approx. 100 thousand JUnit tests. I want run only the subset that are related to may current class. This run should be approx one second or fewer. Manual selecting the test and set the needed command line parameter for mocking will consume many time and will forget in many cases.Conspire
JUnit4 provides rich choice to run subset of all test cases. Use: @RunWith(Suite.class) @Suite.SuiteClasses({ A.class, B.class, ... })Swedenborgianism
Y
0

You can run all tests in a project using Alt+Shift+X,T. I think that making it any more automated than this could take a serious performance toll. Incremental compilation is compiling at most 1 file at a time, but you're talking about running potentially hundreds of tests.

Yammer answered 30/1, 2011 at 9:4 Comment(1)
I does not want run all tests of the project. I want run only the test related to the saved class. We have approx. 100 thousand JUnit tests. This will run to long.Conspire

© 2022 - 2024 — McMap. All rights reserved.