This topic explains how to migrate your C++test 6.x test assets to C++test 10.x.
In this section:
To import Test Configuration from C++test 6.x:
C++test will create a new user-defined Test Configuration with the same name as the C++test 6.x Test Configuration. The following data will be imported from the C++test 6.x Test Configuration:
<rule_category>-<rule_unique_id>
(myrule-123, user-456,
etc.) This way, C++test 10.x will be able to automatically create a rule tree structure based on the rule categories.All other parameters in the new configuration will be set to their default values.
If C++test 10.x cannot access any rules that were enabled in the C++test 6.x Test Configuration, warning messages will display to alert you to the problem.
If any rules are added to the UNKNOWN category, you can use rule mapping to change the category. See Modifying Rule Categories, IDs, Names, and Severity Levels for details.
Test Configurations stored on Team Server need to be imported into the User folder and then reuploaded to Team Server in C++test 10.x format.
There are two ways to import "source test" test suites from C++test 6.x: 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.
Before you import test suites, note that:
To import test suites from a C++test 6.x project:
1. Choose New> Other from the shortcut menu.A wizard will open.
2. Select Import C++test 6.x test suites, then click Next.
3. 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.
4. 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.
5. Modify the following options if desired:
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:
Information about renaming is also available in the C++test console; for example:
|
6. 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.
During the import process, C++test checks test cases for obsolete constructors using __CPTR_Construct_Argument. If any obsolete constructor invocations are found, they will be changed into default constructors invocations. The test case will contain appropriate information, and the original code will be commented out. A warning message will be displayed in the C++test Console. The imported test suite file should be reviewed. If needed, the test cases should be modified to use different constructors.
Importing C++test 2.3 / 6.x Native tests is available in C++test when the appropriate license feature is enabled. This license is required to enable all configuration items related to Native tests (for example, the Add new> Native tests action in the Test Case Explorer, options in the Test Configurations dialog, and Native tests project configuration in the C++test project properties). |
To import native tests from C++test 6.x into C++test 10.x:
C++test will automatically add the existing Native Tests to the Test Case Explorer view. They will be displayed according to the following hierarchy:
[NewProject]
[Native Tests (OldProject.cpf)]
[File1.cpp]
[Class1]
[Function1]
[TestCase1]
[TestCase2]
New test cases should be added using C++test 10.x functionality. If you need to modify a native test case, you can do so in C++test 6.x, then refresh the Test Case Explorer to synchronize.
To run native tests in the current version of C++test:
<INSTALL_DIR>/configs/NativeTests
.'CPPTEST_INSTALL_DIR'
environment variable to the C++test 2.3/6.x installation directory.CPPTEST_INSTALL_DIR=....
command in the bash shell or (on Windows) set up the system environment variable in Control Panel> System> Advanced> Environment Variables.To configure a Test Configuration to run Native test:
|
2. In the Test Case Explorer, select the tests you want to execute.
3. Run the Test Configuration that you created for executing Native tests.
Notes:
The results of native test execution will be presented the same way as for source tests:
You can also:
There are two ways to import "user" stubs from C++test 6.x: import all user stubs into a single file, or import the user stubs for each C++test 6.x Test Unit into a separate file. If you import into a single file, the stub methods are sorted so that duplicated stubs can be easily found. If you import into separate files, the file names correspond to the C++test 6.x Test Unit names.
To import user stubs from a C++test 6.x project:
1. Choose New> Other from the shortcut menu. A wizard will open.
2. Select Import C++test 6.x user stubs, then click Next.
3. 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.
4. 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.
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:
This way, only stubs imported into the 'foo.cpp' subdirectory will be used when C++test is testing foo.cpp file in a File Scope mode. |
5. 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:
6. 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:
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(); } } |
7. If you want C++test to add the specified text at the beginning of each imported stub file, enable 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.
8. If you want C++test to comment out duplicated stubs, enable Comment out duplicated stubs.
9. 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.
C++test will automatically copy #include directives from the original source file (the file that the stub was created for in the C++test 6.x project) into the imported stub file.
The following table shows the differences in command line usage between C++test 6.x and C++test 10.x. An x is used to indicate that no equivalent command is available.
C++test 6.x | C++test 10.x |
---|---|
-Zicpf (file), --Zinput_cpf_project (file) | -data (WORKSPACE_DIR) |
-Zocpf (file), --Zoutput_cpf_project (file) | x |
-Zdsp (file), --Zdsp_project (file) | x |
-Zvcproj (file), --Zvcproj_project (file) | x |
-Zdc (name), --Zdsp_config (name) | x |
-Zdc (name), --Zdsp_config (name) | x |
-Zmcl (param), --Zmake_command_line (param) | x |
-Ztf (name), --Ztest_file (name) | -resource (RESOURCE) |
-Zeh (name), --Zexport_harness (name) | x |
-Zrl (name), --Zread_logs (name) | x |
-Ztc (name), --Ztest_config (name) | -config (CONFIG_URL) |
-Zpc (name), --Zproject_config (name) | x |
-Zso (file), --Zsave_options (file) | x |
-Zitc (file), --Zimport_test_cases (file) | x |
-Zito (file), --Zimport_test_objects (file) | x |
-Zis (file), --Zimport_suppressions (file) | x |
-Zrf (file), --Zreport_file (file) | -report (REPORT_FILE) |
-Zgh (name), --Zgenerate_html (name) | -report (REPORT_FILE) |
-Zhrd (dir), --Zhtml_report_directory (dir) | -report (REPORT_FILE) |
-Zgx, --Zgenerate_xml | -report (REPORT_FILE) |
-Zxrd (dir), --Zxml_report_directory (dir) | -report (REPORT_FILE) |
-Zpr, --Zpublish_results | -publish, -publishteamserver |
-Zf, --Zforce | x |
-Zow {on\off}, --Zoverwrite {on\off} | x |
-Zoe [quiet], --Zonly_errors [quiet] | x |
-Zq, --Zquiet | x |
-Zvm(level), --Zverbosity_mode(level) | x |
-Zgrs {on\off}, --Zgrs {on\off} | -localsettings (LOCALSETTINGS_FILE) |
-Zga (name), --Zgrs_attribute (name) | -localsettings (LOCALSETTINGS_FILE) |
-Zcs, --Zcompile_source | x |
-Zrs, --Zreread_symbols | x |
-Zlc (param), --Zlist_config (param) | x |
-Zecf, --Zexpand_command_files | x |
-Znt --Zno_tests | x |
-h, --help | -help |
-V, --version | -version |
x | -nobuild |
x | -showdetails |
x | -appconsole stdout |