...
To import test suites from a C++test 6.x project:
1.
...
- Choose Parasoft> Wizards> Import C++test 6.x test suites.
...
- A wizard will open
...
- .
...
- In
...
- the C++test 6.x project file
...
- field, enter the location of the C++test 6.x project file. This file should have a .cpf extension.
...
3.
...
In the Imported test suites location
...
field, choose the drop-down menu item for the import strategy you want to use (import all test suites into a single directory, or import the test suites for each C++test 6.x Test Unit into a separate subdirectory), then customize the entered text to specify the location where you want the test suites stored. When specifying the location, you can use the following variables:
${src_file_name}
- Name of the context file (a "context file" is a source file that describes the compilation unit in which the given tested function is defined).${src_file_base_name}
- Name of context file without extension.${src_file_ext}
- Extension of context file.${src_file_loc_rel}
- Context file project relative location.${src_file_uid}
- Context file unique identifier.${unit_name}
- Imported test suite C++test 6.x test unit name.
...
4.
...
Modify the following options if desired:
- Automatically rename duplicated test suite names:
...
- When enabled, C++test will automatically rename an imported test suite if its name conflicts with the name of another test suite in the target project.
- Automatically rename duplicated test suite files:
...
5.
...
- When enabled, C++test will automatically rename an imported test suite file if it conflicts with another test suite file in the target project.
Note title Note - Automated Renaming If C++test renames a test suite or a test suite file, the appropriate information is added to the imported test suite file; for example:
// Test suite was renamed by C++test - original name: TestSuite_XX
// File was renamed by C++test - original file: TestSuite_XX.cpp
Information about renaming is also available in the C++test console; for example:
Importing test suite "TestSuite_XX" ...
...warning, test suite "TestSuite_XX" already exists in the project. Test suite renamed to
...
"TestSuite_XX_1".
- Click
- Finish.
As test cases are imported, progress information will be displayed in the Console view. Progress information includes information about the imported test suites and problems encountered during the import, as well as an import summary.
...
To import user stubs from a C++test 6.x project:
1.
...
- Choose Parasoft> Wizards> Import C++test 6.x user stubs.
...
A wizard will open.
...
2.
...
- A wizard will open. A wizard will open.
- In the
- C++test 6.x project file
...
- field, enter the location of the C++test 6.x project file. This file should have a .cpf extension.
...
...
3.
In the
...
Imported stubs location
...
field, enter the location where you want the stubs stored. You can use the drop-down menu to configure this value to import all stubs into a single directory, import all stubs for the given C++test 10.x Text Context into separate subdirectories, or import all stubs for the given C++test 6.x Text Unit into separate subdirectories.
Note title Note - Reproducing C++test 6.x behavior in C++test 10.3 using File Scope testing mode The Import all stubs for the given C++test 10.x Text Context into separate subdirectories option might be especially useful when trying to reproduce C++test 6.x behavior in C++test 10.x using File Scope testing mode. When importing stubs using the predefined layout, all stubs for a particular C++test 10.x Test Context will be placed in a single directory.
To ensure that the executed tests use the appropriate set of stubs in the File Scope testing mode:
- Create a custom Test Configuration based on Run Unit Tests (File Scope).
- Modify the Execution> Symbols> Use extra symbols from files found in setting to use only context-specific stubs, e.g.:
${project_loc}/stubs/imported/${ctx_name}
...
Thisway,
...
onlystubs imported into the 'foo.cpp'
...
subdirectorywillbeused whenC++test is testing foo.cpp file in a File Scope mode.
...
4.
...
In the Duplicated Stubs Import
...
strategy area, use the available controls to define a strategy for importing several stubs for a single function (for example, if a stub for a given function is defined in the context of several C++test 6.x Test Units). Available options are:
- Import all duplicated stubs:
...
- Tells C++test to import each stub for a given function without performing any special actions.
- Comment out duplicated stubs:
...
- Tells C++test to import only one of the stubs for a given function. All other stubs for this function will be commented out during the import process.
- Merge duplicated stubs (when importing to the same location):
...
- If this is enabled and C++test (
...
- using Imported stubs location) determines that several stubs for the same function are to be added to a single file, C++test
...
- will try to merge all stubs into a single stub definition.
If you want C++test to modify the imported stub definition to ensure that the given stub will be used in the appropriate Test Context,
...
enable Insert code to connect stub definition with C++test 10.x Test Context. For instance:
...
// [...]
...
if (CppTest_IsCurrentContext("Examples/ATM/Source Files/Account.cxx")) {
// [...]
This option is especially useful with the
...
Merge duplicated stubs
...
setting. Here, C++test will create a single stub definition that will behave differently for each
...
Test Context corresponding to the behavior of the C++test 6.x stubs. The default path of a stub will call the original definition of the stubbed function. For example:
Code Block double (::Account::CppTest_Stub_getBalance) () { if (CppTest_IsCurrentContext("/ATM/ATM/Account.cxx")) { //account } else if (CppTest_IsCurrentContext("/ATM/ATM/ATM.cxx")) { //atm } else { return getBalance(); } }
...
- If you want C++
...
- test to add the specified text at the beginning of each imported stub file, enable
...
7.
...
- Insert custom code at beginning of each stub file. For example, this can be used to add a common set of #include directives for required header files to all imported stub files.
...
- If you want C++test to comment out duplicated stubs,
...
8.
...
- enable Comment out duplicated stubs.
...
- Click Finish.
As stubs are being imported, progress information will be displayed in the Console view. Progress information includes details about the stub files created, duplicate stubs identified, and conversion problems encountered, as well as an import summary.
...