Creating a JUnit Test

See Also 

The JUnit test generator allows you to create compilable test classes for use as skeletons in your unit tests. You can create unit tests for single classes and entire packages, as well as empty test skeletons to be used with sources you create later.

To create a test for a single class:

To create a test suite:

  1. Right-click the package node containing the source files for which you want to generate the test suite in the Projects window and choose Tools > Create JUnit Tests (Ctrl-Shift-U) from the contextual menu.
  2. Make sure the Generate Test Suites checkbox is selected, specify any further options, and click OK.

    The IDE generates test classes for all enclosed classes and stores them in the project's Test Packages node. If any of the test classes already exist, those classes are updated.

To create an empty test:

  1. Choose File > New File from the main menu.
  2. In the New File wizard, select JUnit in the Categories pane and Empty Test in the File Types pane. Click Next.
  3. Enter the Test Name and select any options you require. Click Finish.
  4. The test skeleton is created based on the properties specified in JUnit Module Settings.

JUnit Test Creation Options

When you generate JUnit tests from existing classes, you can specify the following options:

See Also
Running a JUnit Test
Configuring JUnit
About JUnit

Legal Notices