Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space CPPTDESKDEV and version 10.3.3

...

Safe stub definitions are automatically-generated to replace "dangerous" functions, which includes system I/O routines such as rmdir(), remove(), rename(), etc. In addition, stubs can be automatically generated for missing function and variable definitions (see Understanding and Customizing Automated Stub Generation for details). User-defined stubs can be added as needed (see Adding and Modifying Stubs for details).

Generating Test Cases
Anchor
Generating Test Cases
Generating Test Cases

...

  1. Identify or create a Test Configuration with your preferred test generation settings.
  2. Run the Test Configuration
    • For details on testing from the GUI, seeTesting from the GUI.
      For details on testing from the command line, see Testing from the Command Line Interface.

      Tip

      Tip - Generating Tests from the Test Case Explorer

      You can generate tests for a project directly from the Test Case Explorer (which can be opened by choosing Parasoft> Show View> Test Case Explorer). Just right-click the project node in the Test Case Explorer, then choose the desired test generation Test Configuration from the Test History or Test Using shortcut menu.

       


      For details about the Test Case Explorer, see Exploring the C++test UI.

  3. Review the generated test cases.
  4. (Optional) Fine-tune test generation settings as needed.

Customizing Generation Options
Anchor
Customizing Generation_Options
Customizing Generation_Options

...

If the Create one test suite per function option is selected, a test suite generated for the sample ATM project (included in the examples directory) would look like this:

 


 


If the Create one test suite per tested source/header option is selected, a test suite generated for the sample ATM project (included in the examples directory) would look like this: 


 

...



After selecting one of these options, you can customize the pattern as needed (for instance, to generate tests into the source location). You can use the following variables when you are customizing the pattern:

...

This section explains how to configure the Test suite output file and layout option (in the Test Configuration’s Generation> Test suite tab) to suit various layout needs. To help you understand how each option discussed translates to actual projects, we show how it would affect the following sample project:

Code Block
MyProject
  headers
    MyClass.h // contains foo() definition
  sources
    MyClass.cpp // contains bar() and goo() definitions

To generate a single test suite file for each function, keep tests in a separate directory

...

Code Block
MyProject
  headers
    MyClass.h
  sources
    MyClass.cpp
  tests
    headers
	MyClass.h
	    TestSuite_foo.cpp // contains tests for foo()
     sources
	MyClass.cpp
	  TestSuite_bar.cpp // contains tests for bar()
          TestSuite_goo.cpp // contains tests for goo()

Use ${project_loc}/tests/${file_loc_rel}/${file_name}/
TestSuite_${function_name}.${test_ext}

Sample layout:

Code Block
MyProject
 Header Files
   MyClass.h
 Source Files
   MyClass.cpp
 tests
   Header Files
     MyClass.h
	TestSuite_foo.cpp // contains tests for foo()
   Source Files
     MyClass.cpp
	TestSuite_bar.cpp // contains tests for bar()
	TestSuite_goo.cpp // contains tests for goo() 

...