Page tree

Skip to end of metadata
Go to start of metadata

Create a  "Generate Stubs" Test Configuration

1. Open the Test Configuration dialog by choosing Parasoft> Test Configurations.

2. Choose Built-in> Unit Testing and right-click the Generate Stubs configuration.

3. Choose Duplicate to copy the configuration to the User-defined category.

4. Open the Execution> General tab on the new user-defined configuration and confirm that the Test execution flow field is set to Generate stubs.

5. Open the Execution> Symbols tab and confirm the following settings:

  • Library Symbols Identification mode is set to Automatic, which is appropriate for most situations.
  • Use symbols from additional project files is selected and set to include all project files (Project Scope).
  • Use extra symbols from files found in is set to the default location. This will prevent stubs from being recreated. By default, any functionality provided by project object/library files will be used.
  • Auto-generated stubs output location is set to $[project] /stubs/autogenerated.

6. Rename the configuration Generate Stubs (Project Scope).

7. Apply the changes and close the Test Configurations window.

When running the stub generation configuration, you should select the same test scope that you intend to run unit tests on.

Run the stub generation configuration

1. Select ATM.cxx as the test scope.

2. Choose Parasoft> Test Using> User-Defined> Generate Stubs (Project Scope).

3. Open the Stubs view and note that the original code will be used for all function calls (as seen in the previous exercise), and that no stubs were generated.


 

Generate Stubs (File Scope vs Project Scope)

If  we want to isolate ATM.cxx from the other files in the project for testing, we need to use a configuration setup for File Scope stub generation.

1. Open the Test Configurations window and duplicate Built-in> Unit Testing> File Scope> Generate Stubs (File Scope).

2. Select the duplicate configuration and choose Execution> Symbols tabs.

3. Disable the Use symbols from additional project files setting.

4. Apply changes and close the Test Configurations window.

5. Select ATM.cxx in the project tree and run the User-Defined> Generate Stubs (File Scope) configuration.

6. Click the Stubs tab to view the results.




 

All symbols are now resolved for file scope testing of ATM.cxx. Original code will be used for all functionality within the ATM.cxx file and auto-generated stubs will be used for all external functionality. 

  • No labels