Okay, your project has hundreds of unit tests, but you only need to execute one or perhaps only all tests from a JUnit test file. Maven allows for that, and Eclipse makes it more convenient.
Eclipse JUnit Run Configuration
With Eclipse, you can perform the following:
- Run all tests in a certain project, package, or source folder
- Run all tests in a JUnit file
- Run a specific test in a JUnit file
All these options are available on the same UI window, as shown below. If you select option 1 from the above list, choose “Run all tests in the selected project, package or source folder.”
Run Only one Test
The following image shows a JUnit run configuration that executes a test method.
Run All Tests from a Test class
To run all tests from a test class, choose “all methods” from a list shown when “Search…” is clicked.
Eclipse Maven Build Run Configuration
Running tests from Maven is slightly different because you need to specify parameters (aka Goals, etc.) as you would when running an application from a command-line prompt.
Run Only one Test
Run All Tests from a Test class
Download the Maven Project
You may download the Maven project used for this post.
https://www.dropbox.com/s/gf79xfdsom4dmla/turreta.com-onetest.zip?dl=0