Creating a Component Test for Ada

Using the Component Testing Wizard, you will now create a test for all functions in the file and CodeCoverage.adb.

To create a component test:

  1. If the Project Explorer window is not visible, from the View menu, select Other Windows and Project Window.

  2. From the Window menu, select Close All.

  3. Click the toolbar Start button to reopen the Start Page.

  4. Select the Activities link on the left-hand side of the Start Page.

  5. Select the Component Testing link.

  6. In the Application Files window, notice how all the Ada source files of your development project are already visible. For this tutorial, you will directly select two additional source files. Click the Add button.

  7. Browse to folder into which you have installed OneTest Embedded and then access the folder \examples\TestSuiteAda\src

Make sure All Ada Files in the Files of type dropdown box is selected, then select the following files:

Now click the Open button.
You should see all the source files in the list of the Application Files page.

Select the Compute static metrics option. This allows the measurement of code complexity from which you can prioritize your test campaign.

Click the Next button.

  1. In the Components Under Test window, you are asked to specify which functions you would like to test. There are a variety of ways for making this decision. One method is to use the static metrics that have just been automatically calculated. Certain measurements of code complexity are listed for you:


Sorting by any of these metrics columns - by left-clicking a column header - lets you prioritize your test selection, choosing the more complicated functions first.

Additional metric information can be viewed by selecting the Metrics Diagram button on the lower right-hand side of the screen. Selection of this button opens a graph enabling visualization of two, selected static metrics graphed against one another. Select a data point in this graph to indicate your desire to test the associated functions.

For this Tutorial, your test selection is based on the desire to increase code coverage, so the static metrics do not affect your decision.

  1. Click the box to the left of the CodeCoverage.adb file.

  2. Click the Next button.

In the Test Script Generation Settings window, you are asked to make two decisions

  1. Type MyAdaTest in the Test Name field. Leave the default selections. You will be creating a single test script that automatically stubs all referenced but undefined functions. Click the Next button.

  2. You should now be viewing the Summary window. Click the Next button.

The Component Testing Wizard now analyzes the source code in CodeCoverage.adb and and creates a test for every function within it.

  1. When test script generation has completed, click the Finish button.

In the Project Browser tab of the Project Explorer window on the right-hand side of the screen, you should now see a component test node named MyAdaTest.