Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. If the Unit Test Assistant View is not already open, choose Parasoft> Show View> Unit Test Assistant from the Eclipse menu bar.
  2. Select the method in the editor.
  3. Click the Add test case(s) button in the UTA interface.

    Alternatively, you can right-click a class in the editor and select Unit Testing> Add test case(s) from the context menu.


    The Unit Test Assistant - Add test case(s) dialog will open.
  4. Select the Parameterized option (see Creating Multiple Unit Tests for information about other options).


  5. (JUnitParams only) If you use the JUnitParams framework, customize the following options:
    - The maximum number of parameter sets created for one test case specifies the maximum number of rows with parameter variants that will be created for one test case.
    - Generate test data to specifies where the test cases will be saved. Choose Code (default) or CSV from the drop-down menu. CSV supports UTF-8 character encoding.

    Info
    titleAbout CSV
    • CSV supports UTF-8 character encoding.
    • The CSV files are saved in the same folder as your Java files. If the location does not match the resource folder specified by your build system, copy the CSV files to the appropriate location.
    Info

    If you use the JUnitParams framework, ensure that the JUnitParams library is added to your Eclipse project.

  6. Specify the object initialization mode:
    Deep - (default) Prepares objects and mocks using data collected from the tested method and other methods that are called when the test is executed.
    Shallow - Prepares objects and mocks using data collected from the tested method.
  7. (Optional) Enable or disable the Timeout for running created tests (in ms) option and specify the time limit (in milliseconds) for executing this set of test. If the time limit is exceeded, the test execution will stop and the test will fail. The information about the error will be displayed as a Recommendation in the UTA interface. This option is enabled and set to 1000 by default.
  8. Select the methods you want to create test cases for.
  9. Click OK.
  10. View the tests to modify the values and uncomment sample assertions. If you use the JUnitParams framework, your test cases will include the preconfigured parametrization data (see Configuring Preferences to view and customize the settings).
  11. Run the test with UTA to collect coverage information and recommendations for possible improvements (see Executing Unit Tests with Unit Test Assistant).

...