The following table describes common JUnit tasks.
To perform this task |
Follow these steps |
Create a test for a single Java class. |
- Select the class in the Source Editor, Projects window, or Files window
and choose Tools > Create JUnit
Tests (Ctrl-Shift-U).
- Set the parameters for the test skeleton generator in the Create Tests
dialog box and click OK.
|
Create a test suite for a package. |
- Right-click the package node in the Projects window and choose Tools
> Create JUnit Tests (Ctrl-Shift-U).
- Set the parameters for the test skeleton generator in the Create Tests
dialog box and click OK.
|
Create an empty test or test suite. |
- Choose File > New File.
- Select JUnit in the Categories pane and the appropriate test type
in the File Types pane. Click Next.
- Enter a name, target package and other required information, and set
any required options.
- Click Finish.
|
Run a test for a class. |
- Select the node of the class whose test you wish to run.
- Choose Run > Run File > Test
classname
(Ctrl-F6).
|
Run tests for an entire project. |
- Select any node in the project for which you wish to run tests.
- Choose Run > Test project
name (Alt-F6).
|
Debug a test. |
- Select the class whose test you wish to debug.
- Choose Run > Run File > Debug
Test for classname
(Ctrl-Shift-F6).
|
Configure JUnit. |
- Choose Tools > Options.
- Click Advanced Options.
- Select Testing > JUnit Tests node.
|
Configure the test classpath. |
- Right-click a project's Test Libraries node in the Projects window
and choose one of the following:
- Add Project
- Add Library
- Add JAR/Folder
|