Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a selected set of unit tests in Eclipse with one mouseclick?

I want to create a launcher/run configuration which runs only the JUnit tests in a selected set of test classes or selected set of packages. Now it looks like I'll have to create separate run configurations for each of my packages containing the tests I want to run. I also have a recollection of this working in older versions of Eclipse.

And yes, I know: The tests should be organized so that I wouldn't have this problem but reorganizing source folders right now is not an option.

I'm using Eclipse 3.4.2.

like image 951
auramo Avatar asked May 27 '09 06:05

auramo


People also ask

How do I run all JUnit tests at once?

In order to run all of the tests in a directory including tests in nested directories you will need to use something like googlecode. junittool box. Right clicking on this class and selecting Run As JUnit test runs all of the tests in the specified directory including all tests in nested subfolders. Save this answer.

How do I run a specific method in Eclipse?

Press Alt+Shift+X,T to run the test (or right-click, Run As > JUnit Test). If you want to rerun the same test method, just press Ctrl+F11. For this to work, ensure that you've told Eclipse to always run the last launched application.


2 Answers

You could add a test suite for the selected tests.

I would put them in a separate source folder, as otherwise tests will be run multiple times, once for the original test and once for each suite it is in.

like image 41
starblue Avatar answered Nov 16 '22 22:11

starblue


You can create a JUnit test suite like this :

JUnit Test Suite

like image 143
Valentin Rocher Avatar answered Nov 16 '22 20:11

Valentin Rocher