5

I know Eclipse provides means to run a single JUnit 4 test method separatly (see Running a single JUnit test in Eclipse).

Now, I wonder whether there is a way to run a single test method for a given concrete class when the class does not contain the method but instead inherits it from an abstract base class.

Community
  • 1
  • 1
Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106

2 Answers2

4

This works fine, the difficulty is selecting the method.

If you try and run the whole suite of tests, and then right click on the test you want in the "JUnit" view, then click "Run", it will run just that test.

If you then look in your "Run Configurations" you will see it has created a run configuration which relates to a single test which you can re-run whenever needed.

Alternatively, you can open the "Run Configurations" dialog, and create a new "Junit" run configuration, which gives you the option to configure a "single test" run - you can then select the correct project, class and method for your test.

0

you can then select the correct project, class and method for your test.

With Eclipse 2.29 (Q3 2023), you also have a new progress dialog and a progress bar, which have been added to the Run/Debug configurations of JUnit tests.

If the configuration references a test method, then a search takes place, which sometimes requires some time and led previously to a UI freeze.
There is now a progress indication in the form of a progress dialog when first opening the Run/Debug Configurations dialog:

JUnit search progress dialog

Or in the form of a progress bar if the dialog is already opened:

JUnit search progress bar

In case the search is canceled by the user, the cancelation will be reported in the notification area of the Run/Debug Configurations dialog, the text field Test method: will be disabled and the Run/Debug button will be disabled. The Search... button right next to Test method: remains enabled and triggers the search again.

JUnit search progress Run Configuration

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250