Versions Compared

Key

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

With Unit Test Assistant you can easily create multiple test cases for methods from a selected class, as well items selected in the Project Explorer. The methods are analyzed to create runnable test cases with initial values and sample assertions, which can be easily modified or uncommented. You can add test cases using the UTA interface or the Eclipse context menu.

Info
iconfalse

If you create multiple test cases for a large code base, we recommend configuring Eclipse to use 2 GB of RAM or more.

  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 a class in the editor.
  3. Click the Add test case(s) button in the UTA interface:

    Info
    titleMultiple Spring Tests

    If you are creating multiple tests for Spring controller methods, the button label will change into Add Spring test case(s). See Creating a Spring Unit Test for more information about creating and configuring Spring unit tests with UTA.

    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.  Specify the test type:
    - Regular - Creates regular test cases.
    - Parameterized - Creates parameterized test cases (see Creating a Parameterized Unit Test for details).
    - Combined - Creates parameterized test cases for methods that can be tested against different arguments. For other methods, regular tests are created.



  5. 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.
  6. (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.
  7. Select the methods you want to create test cases for (you can use the Select All or Deselect All buttons for your convenience).

    Info
    titleMultiple Spring Tests

    If you are creating multiple Spring tests, you can click the Select Spring Handler Methods button to select all the Spring controller methods and deselect all the other methods in the list.


  8. Click OK.
  9. View the tests to modify or uncomment the default UTA values if necessary.



  10. Run the test with UTA to collect coverage information and recommendations for possible improvements (see Executing Unit Tests with Unit Test Assistant).

...