13

I practice TDD and run my tests very often. Eclipse has a nice command to run the last-launched configuration. But when I invoke the command in some unit test class, Eclipse runs only the tests for current unit test class. I want run all my unit tests instead. Yes, I can use the mouse to invoke the command that runs all JUnit tests, but, to repeat: I run tests very often.

dmitrynikolaev
  • 8,994
  • 4
  • 30
  • 45

5 Answers5

20

You need to change eclipse's run mode. By default, it will try to run whatever is selected or being edited. You want to it always run the "last thing executed".

Go to Window->Preferences->Run/Debug->Launching Choose "Always Launch the Previous Application"

Then you can define a TestSuite with all of your test cases and run it, or run all test cases for the project. Once run, you can just keep re-running with F11 or control-F11.

Hope this helps! -- Scott

Scott Stanchfield
  • 29,742
  • 9
  • 47
  • 65
2

Maybe Infinitest is what you need.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • I love Infinitest, but I find it a little unreliable with large multi-module Maven solutions and also when the tests are doing something a little unusual (e.g. using Hazelcast). You can use a filter to exclude tests though, and that helps a little. – brindy Jun 15 '12 at 08:50
1

You can create a JUnit launch configuration for all of your tests by right clicking the tests folder and choosing "Run As > JUnit Test".

Then see https://stackoverflow.com/a/8176077/255961 which describes how to use the Practically Macro plugin to assign shortcuts to launch configurations.

PS, If for some reason you have tests in more than one folder you can then edit the JUnit launch configuration to work at the project level as well: editing a JUnit launch config

Community
  • 1
  • 1
studgeek
  • 14,272
  • 6
  • 84
  • 96
0

There is also Junit Max. It is not free but very cheap. It will run all your tests every time you save a file and indicate if the tests were successful in the right bottom corner of eclipse.

If a tests fails the line where it fails is marked as an error so you can keep working with the source files and don't have to wait for your tests and have your workflow interrupted.

Carl Manaster
  • 39,912
  • 17
  • 102
  • 155
Janusz
  • 187,060
  • 113
  • 301
  • 369
0

To run all unit tests in a project, package or source root, select the item in the package explorer and hit Shift+Alt+X then T (or right click->Run As-> JUnit test).

To get the focus on the package explorer, hit Ctrl+F7 to bring up the "Next View" menu, hit it repeatedly to cycle through the list or hit up and down arrow then enter to select the view.

Once you've run it once, F11 can be set to run the last launched if you tweak the debug preferences (the default is to run for the current selection).

Rich Seller
  • 83,208
  • 23
  • 172
  • 177