Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 439
Horcrux7 Avatar asked Jan 30 '11 09:01

Horcrux7


People also ask

How do I run JUnit tests automatically?

To run JUnit 5 tests from Java code, we'll set up an instance of LauncherDiscoveryRequest. It uses a builder class where we must set package selectors and testing class name filters, to get all test classes that we want to run.

Can we automate JUnit?

JUnit is best at creating repeatable test cases. If there is a need to run a test in JUnit 100 times, one doesn't need to write it 100 times or not even execute it manually 100 times. This process is automated. Automation testing is usually preferred over manual testing because of faster and reliable results.

Can JUnit tests be debugged in Eclipse?

In the case of a test failure you can follow these steps to debug it: Double click the failure entry from the Failures tab in the JUnit view to open the corresponding file in the editor. Set a breakpoint at the beginning of the test method. Select the test case and execute Debug As>JUnit Test from the Debug drop down.

Is JUnit automated testing?

JUnit is an open source unit testing tool that helps to test units of code. It is mainly used for unit testing Java project, however, it can be used with Selenium Webdriver to automate testing of Web applications. So you can even perform automation testing of a web application with JUnit.


2 Answers

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.

like image 103
Romain Linsolas Avatar answered Oct 13 '22 12:10

Romain Linsolas


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:)

like image 29
卢声远 Shengyuan Lu Avatar answered Oct 13 '22 11:10

卢声远 Shengyuan Lu