Running a Unit 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 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 (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.
- You can select multiple projects in the Projects window and run tests for them at once by choosing Run > Test (number of selected projects) Projects (Alt-F6) from the main IDE's menu.
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 > Test File (Ctrl-F6).
- You can also run a class's test by right-clicking the test class node itself in the Projects window
and choosing Test File (Ctrl-F6).
To run a single test method:
- Run the test class or suite containing the test method.
- In the 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 Test Results window.
Working with Unit Test Output
When you run a test, the IDE shows the test results in two panes in the 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.
You can use the filter icons in the left side of the window to filter the test results.
- The textual output from the unit 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.
you can double-click any error to jump to the line in the code where the error occurred.
- See Also
- Creating a Unit Test
- About Running Java Applications
Legal Notices