Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space ENGINES1031 and version 10.3.3


  1. Ensure that the options for creating mocks have been configured (see Configuring PreferencesMocking Options).
  2. Create a new unit test with UTA  (see Creating a Basic Unit TestCreating Multiple Unit Tests or Creating a Parameterized Unit Test). By analyzing source code, UTA will detect complex objects that cannot be incorporated and add a mock object to the test.

  3. Execute the test and view the results in the UTA interface (see Executing Unit Tests with Unit Test Assistant). 

    The Recommendations section displays information about interactions with mock objects. Clicking the Highlight link helps you view these interactions in execution flow displayed in the left column. The nodes marked in brown indicate the mock object. The nodes in bold indicate interactions with the mock object. Double-clicking the nodes navigates the test code.


  1. Go to Parasoft> Preferences> Unit Test Assistant in your IDE menu bar.
  2. Enable the Mockable static invocations (requires PowerMock) option in the Recommendations section (see Configuring PreferencesMocking Options for details).
  3. Go to Parasoft> Preferences> Unit Test Assistant>Mocking.
  4. Select the Enable check box to enable creating unit tests with mocks.
  5. Select the PowerMock with Mockito framework.
  6. Complete the Static methods to mock (requires PowerMock) table with a list of static methods that you want to be mocked. Click New and provide a qualified method name or pattern using wildcards. UTA will mock only the static methods that are specified in the table. 

    Alternatively, you can add static methods to the list after you execute your tests (see Executing Unit Tests with Unit Test Assistant for details). Right-click a node that represents a static method in the execution flow and choose the Add Mockabe Method Pattern option. Selecting the Mock Static Method option will update your code to mock the selected method call, but the method will not be added to the table; see Executing Unit Tests with Unit Test Assistant for details.

    If UTA detects invocations of the specified static methods in the tested code during test creation, mocks will be included in the generated test templates (see Creating a Basic Unit Test).

  7. Run your unit tests with UTA (see Executing Unit Tests with Unit Test Assistant). UTA will detect calls to the specified static methods and display the Recommendations that allow you automatically create mocks.
  8. Click the Mock static call action link.

    The specified static method will be mocked with the with the mockStatic method.