Creating a component test

The Component Testing Wizard helps you create a new Component Testing test node in your project for C, C++ and Ada.

For each script type, the wizard analyzes the source code under test to extract unit information and will produce a corresponding test script template using the following test script types:

  • C Test Script Language

  • C++ Test Driver Script Language

  • C++ Contract-Check Language

  • Ada Test Script Language

  • JUnit Test Harness

You use the generated test script template to elaborate your own test cases.

You can later add to this test node any of the runtime analysis features included in HCL OneTest Embedded.

There are two methods of creating a test node with the Component Testing wizard:

  • From the Start page: this method allows you to specify a set of files or components to test.

  • From the Asset Browser: this method rapidly creates a test from a single file or source code component selected in the Asset Browser.

Once the test node has been generated, you can complete your Component Testing test scripts in the Text Editor. Refer to the HCL OneTest Embedded Reference section of the help for information about the actual language semantics.

To run the Component Testing Wizard from the Start Page:
  1. Use theStart Pageor theFilemenu to open or create a project. Ensure that the correct Configuration is selected in theConfiguration box. The selected programming language impacts the type of Component Testing test node to be created.
  2. On the Start Page, select Activities and choose the Component Testing activity.
  3. On the Application Files page, use the Add and Remove buttons to build a list of source files and header files (for C and C++) to add to your project. The Configuration Settings button allows you to override the default configuration settings.
  4. Select Compute Static Metrics to run the analysis of static testability metrics.
  5. Click Next to continue.
    Note: If the static metrics analysis takes too much time, you can clear the Compute Static Metrics option. In this case, the calculation and display of static metrics in any further steps are disabled.
    Note: With Component Testing for Ada, it is not possible to submit only an Ada procedure file. Instead, you must include the single procedure in a package.
  6. On the Components Under Test page, select the units or files for the selected source files. In order to help you choose which components you want to test, this page displays the metrics for each file or unit (packages, classes or functions depending on the language).
  7. Select File Selection to choose files under test or Unit Selection to choose the source code units that require testing. The selection mode toggles the static metrics displayed between file metrics or unit metrics.
    Note: If the Unit Selection view seems incomplete, cancel the wizard, from the Project menu, select Refresh File Information and restart the wizard.
  8. Click Metrics Diagram to select the units under test from a graph representation.
  9. Click Next to continue or Generate to skip any further configuration and to use default settings.
  10. On the Test Script Generation Settings page, specify the test node generation options. The General settings specify how the wizard creates the test node.
    • Test Name:Enter a name for the test node.
    • Test Mode:Disables or enables the test boundaries.
    • Typical Mode:No test boundaries are specified. This is the default setting.
    • Expert Mode:This mode allowing you to manually drive generation of the test harness. This provides more flexibility in sophisticated software architectures.
    • Node Creation Mode: Selects how the test node is created:
      • Single Mode:In C and Ada, this mode creates one test node for each source file under test. In C++, it creates one test node for all selected source code components.
      • Multiple Mode:This creates a single test node for each selected source code unit.
    The Components Under Test settings specify advanced settings for each component of the test node. These settings depend on the language and Configuration.
  11. Click Next to continue.
  12. Review the Summary. This page provides a summary of the selected options and the files that are to be generated by the wizard.
  13. Click Next to create the test node based on this information.
  14. The Test Generation Result page displays progression of the test node creation process. Click Settings to set the Configuration Settings. You can always modify the test node Configuration Settings later if necessary, from the Project Explorer.
    Note: If you apply new settings after the test generation, the wizard reruns the test generation. This allows you to fine-tune any settings that may cause the test generation to fail.
  15. Once a test node has been successfully generated, click Finish to quit the Component Testing Wizard and update the project.
To run the Component Testing Wizard from the Asset Browser:
  1. Use the Start Page or the File menu to open or create a project.
  2. Ensure that the correct Configuration is selected in the Configuration box. The selected programming language impacts the type of Component Testing test node to be created.
  3. In the Project Explorer, select the Asset Browser tab.
  4. Right click an object, package or source file under test. From the pop-up menu, selectTest.
  5. On the Test Script Generation Settings, specify the test node generation options. The General settings specify how the wizard creates the test node.
    • Test Name: Enter a name for the test node.
    • Test Mode: Disables or enables the test boundaries.
    • Typical Mode: No test boundaries are specified. This is the default setting.
    • Expert Mode: This mode allowing you to manually drive generation of the test harness. This provides more flexibility in sophisticated software architectures.
  6. The Components Under Test settings specify advanced settings for the component of the test node. These settings depend on the language and Configuration.
  7. Click Next to continue.
  8. Review the Summary. This page provides a summary of the selected options and the files that are to be generated by the wizard.
  9. Click Next to create the test node based on this information.
  10. The Test Generation Result page displays progression of the test node creation process. ClickSettingsto set the Configuration Settings. You can always modify the test node Configuration Settings later if necessary, from the Project Explorer.
    Note: If you apply new settings after the test generation, the wizard reruns the test generation. This allows you to fine-tune any settings that may cause the test generation to fail.
  11. Once a test node has been successfully generated, click Finish to quit the Component Testing Wizard and update the project.

Related Topics

Component Testing for C and Ada | Component Testing for C++|