Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To import test suites from a C++test 6.x project:

       1.

...

  1. Choose New> Other from the shortcut menu.

...

  1.  A wizard will open.

...

...

  1. Select Import C++test 6.x test suites, then click Next.

...

     3.

  1. In the C++test 6.x project file

...

  1.  field, enter the location of the C++test 6.x project file. This file should have a .cpf extension.

...


...

     4.

...

  1.  In the Imported test suites location

...

  1.  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.


  1.  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:

...

      •  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
    titleNote - 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".

...

     6.

  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. 

...

  1. Choose New> Other from the shortcut menu.

...

  1. A wizard will open.

...

...

  1. Select Import C++test 6

...

     3.

...

  1. .x user stubs, then click Next.
  2. In the C++test 6.x project file

...

  1.  field, enter the location of the C++test 6.x project file. This file should have a .cpf extension.

...

     4.

...

  1. 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
    titleNote - 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:

    1. Create a custom Test Configuration based on Run Unit Tests (File Scope).
    2. 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}

...

  1. Thisway,

...

  1. onlystubs imported into the 'foo.cpp'

...

  1. subdirectorywillbeused  whenC++test is testing foo.cpp file in a File Scope mode.

...

     5.

...

  1.  In the Duplicated Stubs Import

...

  1. 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

...

     6.

...

      • to merge all stubs into a single stub definition.
  1. 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,

...

  1. enable Insert code to connect stub definition with C++test 10.x Test Context. For instance:

...

  1.            // [...]

...

  1.   
         if (CppTest_IsCurrentContext("Examples/ATM/Source Files/Account.cxx")) {
         // [...]

    This option is especially useful with the

...

  1.  Merge duplicated stubs

...

  1.  setting. Here, C++test will create a single stub definition that will behave differently for each

...

  1. 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();
    	}
    }

...

     7.

...

  1. If you want C++

...

  1. test to add the specified text at the beginning of each imported stub file, enable

...

     8.

...

  1.  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.

...

  1. If you want C++test to comment out duplicated stubs,

...

     9.

...

  1. enable Comment out duplicated stubs.

...

  1. 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.

...