Introduction

Executing tests within Unit Test Assistant allows you to collect data about the execution flow and use this data to improve the test quality. UTA can analyze a test case during execution to identify issues and display recommendations on how the test can be enhanced.  It also automatically collects coverage information for all tests run within the Unit Test Assistant interface. 

Running Tests with Unit Test Assistant

  1. If not already open, choose Parasoft> Show View> Unit Test Assistant from the Eclipse menu bar.
  2. Specify the test(s) you want to execute. You can make a selection in the Package Explorer, open a test in the editor or select an element in a source file to automatically detect associated tests.
  3. In the UTA interface, click Run test[method_name] to run the test for the selected method or Run All to run all tests in the method's class.

Viewing Execution Results 

When you run a test, information about execution is displayed in the IDE's built-in JUnit view (Eclipse) or Run tool window (IntelliJ), and in a number of dedicated UTA views:

(info) To stop test execution in IntelliJ, we recommend that you use the Exit button to terminate gracefully and obtain Recommendations for the tests that have been run. Clicking the Stop button prevents UTA from generating Recommendations.

Unit Test Assistant View

After test execution, the UTA view displays execution details the Unit Test Assistant view. Execution flow data is displayed as an expandable tree that helps you analyze execution flow and navigate your code.

  • Double-click a tree node to highlight the code associated with that element in the editor. 
  • Right-click a node to view the navigation, expand and collapse options.
    - Go To - Highlights the selected method call in the editor.
    Go To Declaration - Navigates to the method declaration.
    - Expand Children - Expands the children nodes.
    - Collapse Children - Collapses the children nodes.

     
  • Right-click a node that represents a static method or a constructor and choose one of the following mocking options:
    - Add Mockable Method Pattern - Adds the method or constructor to the list of static methods to be mocked with Mockito (see Configuring Mocking Options).
    - Mock Static Method - Updates the code to mock the selected method call with the spy() method (see Configuring Mocking Options for details).
    Mock Constructor - Updates the code to mock the selected constructor.

    The mocking options require mocking to be enabled and Mockito to be selected as the mocking framework; see Configuring Mocking Options.

Recommendations View

The Recommendations view displays recommendations for test improvements. You can customize what type of recommendations UTA will report; see Configuring Preferences for details.

The total number of recommendations is displayed at the top of the Recommendations view. By default, all available recommendations are displayed, but you can filter out a specific recommendation type you want to focus on.

UTA displays recommendations for test code that was analyzed when the tests are run. If you change your code after test execution, the displayed recommendations may not be up to date.

See About Recommendations for information how to work with recommendations to improve your test quality.

Variables View

 The Variables view displays variables associated with method calls. The view shows the values associated with method calls that can be used to compare the state of an object before and after a method call. See Tracking Object Changes and Creating Assertions for details.


  • No labels