JUnit Tasks: Quick Reference

The following table describes common JUnit 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 JUnit Tests (Ctrl-Shift-U).
  2. 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 JUnit Tests (Ctrl-Shift-U).
  2. Select the Generate Test Suites option in the Create Tests dialog box.
  3. 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 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. Select the node of the class whose test you wish to run.
  2. Choose Run > Run File > Test classname (Ctrl-F6).
Run tests for an entire project.
  1. Select any node in the project for which you wish to run tests.
  2. Choose Run > Test project name (Alt-F6) from the main menu.
Debug a test.
  1. Select the class whose test you wish to debug.
  2. Choose Run > Run File > Debug Test for classname (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