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.
问题:
回答1:
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
回答2:
Maybe Infinitest is what you need.
回答3:
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:
回答4:
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).
回答5:
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.