This section explains how you can test your source code through a Test Project and when it is recommended.

Introduction

A Test Project is an Eclipse project that is dedicated for running tests. It can be created based on the selected Build Targets. A Test Project:

  • contains links to all source files from the original project
  • uses the build options from the original project
  • contains C++test's test cases and stub files 

We recommend using Test Projects for testing multi-layer projects that include a root project with a number of sub-projects attached.  Directly testing such projects (without using a Test Project) limits the scope of testing to one project in the hierarchy. This means that the testing actions you perform on the root project exclusively apply to the resources included in this project–the sub-projects will not be tested. A Test Project can serve as a root for all the project in the hierarchy, ensuring that all the resources are included in the testing scope.

In addition, you can use Test Projects to to provide a better separation of testing components (such as test cases and stubs) from the original source code.

Creating Test Projects

You can create a Test Project using the Create Test Project option in the Project Explorer context menu–it opens a wizard that guides through the process of creating a Test Project. This option is available project nodes that represent build targets. Right-click the node and select Parasoft Test> C/C++test> Create Test Project.

Configuring Test Projects

You can configure a Test Project using the Test Project Reference page in the Test Project properties. It allows you to change the set of build targets that are initially included when the Test Project is created. Right-click the Test Project and select Properties, then go to Parasoft> C++test> Test Project References.

The Test Project References page includes a table with the list of Build Targets that are referenced by the Test Project. When you choose the Refresh Test Project command, C/C++test will try to collect build flag information for all the resources referenced in this list (see Refreshing the Test Project).

  • To add new Build Targets, click Add, select the build target(s) you want to add, then click OK.
  • To remove targets, select the entry you want to remove, then click Remove. C/C++test will skip this Build Target in build flags scanning action in all subsequent refreshes of the Test Project.

Maintaining Test Projects

A Test Project requires maintenance to ensure that it is in sync with the original project for which it was created. In most cases, maintenance involves:

  • refreshing the build data file to reflect changes in the build options of the original project
  • linking the resources that were added to the original project
  • unlinking the resources that were removed form the original project
  • adding/removing the Build Targets that are referenced by the test project

Refreshing the Test Project

You should refresh the Test Project every time you change the build flags in the original project. In Project Explorer, right-click the Test Project, and choose Parasoft> C/C++test> Refresh Test Project. C/C++test will rescan the Build Targets referenced by the Test Project (Test Project References Page) and refresh the build data file.

Linking Additional Resources

When a Test Project is created, it is linked to all directories containing source files that were complied while the referenced Build Targets were built. To link the Test Project with resources that were added after the Test Project was created, you need to manually add the link–using the standard Eclipse mechanism for adding linked resources  (New> File/Folder> Advanced, Link to file/folder in file system).

(info) We strongly recommend using linked resource rather than making copies of existing resources.

Unlinking Resources Removed From Referenced Build Targets

When a Test Project is created, it is linked to all directories containing source files that were complied while the referenced Build Targets were built. The links are not automatically updated after the Test Project is created. You need to manually remove the links to resources that were removed form the referenced Build Target after the Test Project was created—using the standard Eclipse facilities for removing linked resources.

Modifying the List of Referenced Build Targets

If the test project is created from more then one Build Target, you may need to manually update the list of referenced Build Targets.

  1. In Project Explorer, right-click the Tested Project and select Properties.
  2. Go to Parasoft> C++test> Test Project References to open the Test Project References page.
  3. Add or remove the Build Target and click OK.
  4. Refresh the Test project (see Refreshing the Test Project).

Changing Build Specs

It is common practice to work with more than one Wind River Workbench project's Build Spec for a given project. In such a case, when the active Build Spec is changed in the original project, you can pick up a new compiler/linker flags by refreshing the project (see Refreshing the Test Project). You do not need to create a separate test project for every Build Spec.


  • No labels