Unit Testing Tasks: Quick Reference

The following table describes common unit testing tasks.

To perform this task Follow these steps
Create a test for a single Java class.
  1. Select the class in the Source Editor, Projects window, or Files window and choose Tools > Create Tests (Ctrl-Shift-U).
  2. Select a unit test framework.
  3. Set the parameters for the test skeleton generator in the Create Tests dialog box and click OK.
Create a test suite for a package.
  1. Right-click the package node in the Projects window and choose Tools > Create Tests (Ctrl-Shift-U).
  2. Select a unit test framework.
  3. Select the Generate Test Suites option in the Create Tests dialog box.
  4. Set any additional parameters for generating the test skeletons. Click OK.
Create an empty test or test suite.
  1. Choose File > New File.
  2. Select JUnit or TestNG in the Categories pane and the appropriate test type in the File Types pane. Click Next.
  3. Enter a name, target package and other required information, and set any required options.
  4. Click Finish.
Run a test for a class.
  1. In the Projects window, select the class whose test you wish to run.
  2. Choose Run > Test File (Ctrl-F6).
Run tests for an entire project.
  1. In the Projects window, select any node in the project for which you wish to run tests.
  2. Choose Run > Test Project (project name) (Alt-F6) from the main menu.
Debug a test.
  1. In the Projects window, select the class whose test you wish to debug.
  2. Choose Debug > Debug Test File (Ctrl-Shift-F6) from the main menu.
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

Legal Notices