Unit Test Framework : Mocks : Using Mocks
Using Mocks
Mocks are used when resources that a service may require to properly execute may not be available when a test case or test suite is developed or executed. Mocks provide a means of simulating interaction with resources that are unavailable.
To create a mock
1. Expand the test case for which you want to define the mock, right click on Mocks and select Add.
2. Click Browse and use the Service Browser to select the service to be mocked.
3. Enter the first few characters of the service name to reduce the list. Click to refresh the list and access preferences for the Service Browser.
4. Select the required Lifetime.
Valid selections are test (mock is effective only for the selected test case) and suite (mock will be effective for all of the test cases that follow in the test suite).
5. Select the required Type.
Following are the valid selections:
Type
Function
pipeline
Intercepts the service and returns the specified pipeline (for details on creating or editing pipeline data see Inputs ).
service
Intercepts the service and substitutes the selected service with a call (for details on working with the Service Browser, see Service Details).
exception
Intercepts the service and returns an exception (for details on selecting exception classes, see Expected Output).
factory
Intercepts a call to the mocked service and returns the data based on the input (for details on creating a mock factory, see Sample Mock Factory).
6. Select the scope.
It is recommended to use the session scope for most purposes. To allow the scope selection, select the corresponding preference.
Copyright © 2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback