Running a JUnit Test
See Also
Once you have created a test or test suite, you can use the Run Test command
to initiate execution of the test. Run Test commands are available on source nodes only.
After you run a test, you can choose to rerun individual test methods
executed during the test and displayed in the JUnit Test Results window.
To run tests for an entire project:
- Select any node or file in the project you want to test in the Projects
or Files window.
- From the main menu, choose Run > Test project_name (Alt-F6).
The IDE executes all of the project's tests.
- If you want to run a subset of the project's tests or run the tests in a specific order,
you can create test suites that specify the tests to run as part of that suite.
After creating a test suite you run the suite in the same way you run a single test class.
To run a test for a single class:
- Select the node of the class for which you want to run a test in the Projects
or Files window.
- From the main menu, choose Run > Run File > Test classname
(Ctrl-F6).
- You can also run a class's test by selecting the test class node itself
and choosing Run > Run File > Run testclassname (Shift-F6).
To run a single test method:
- Run the test class or suite containing the test method.
- In the JUnit Test Results window, right-click the test method and choose Run Again.
- To run a single test method the method must be listed in the JUnit Test Results window.
Working with JUnit Test Output
When you run a test, the IDE shows the test results in two tabs in the JUnit Test Results window:
- A summary of the passed and failed tests and the description of failed tests
are displayed in the left pane of the window.
Click the filter button (
)
to switch between viewing all test results and viewing only the failed tests.
- The textual output from the JUnit tests themselves is displayed in the right pane of the window.
- The output from the Ant process that builds and runs the test is displayed in the Output window.
Double-click any error to jump to the line in the code where the error occurred.
- See Also
- Creating a JUnit Test
- About Running Java Applications
Legal Notices