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
- If not already open, choose Parasoft> Show View> Unit Test Assistant from the Eclipse menu bar.
- 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.
- 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 Eclipse JUnit view and a number of dedicated UTA views.
JUnit View
The Eclipse JUnit view automatically opens to display general information about test run progress and status.
Unit Test Assistant View
After test execution, the UTA view displays execution details the Unit Test Assistant view. Execution flow data is displayed 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 options.
Go To - Highlights the selected method call in the editor.
Go To Declaration - Navigates to the method declaration. - Right-click a node and choose Expand Children or Collapse Children to expand or collapse its 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 PowerMock (see Configuring Mocking Options).
- Mock Static Method - Updates the code to mock the selected method call with thespy()
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 PowerMock with 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.