Using the Component Testing Wizard, you will now create a test for all functions in the file CodeCoverage.ads and CodeCoverage.adb.
To create a component test:
If the Project Explorer window is not visible, from the View menu, select Other Windows and Project Window.
From the Window menu, select Close All.
Click the toolbar Start button to reopen the Start Page.
Select the Activities link on the left-hand side of the Start Page.
Select the Component Testing link.
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.
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
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.
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:
V(g) - Also called the Cyclomatic Number, it is a measure of the complexity of a function that is correlated with difficulty in testing. The standard value is between 1 and 10. A value of 1 means the code has no branching. A function's cyclomatic complexity should not exceed 10
Statements - Total number of statements in a function.
Nested Level - Statement nesting level.
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.
Click the box to the left of the CodeCoverage.adb file.
Click the Next button.
In the Test Script Generation Settings window, you are asked to make two decisions
If you've selected more than one function to test, do you want all functions to be part of the same test script (Single Mode) or do you want each function to be assigned to its own test script (Multiple Mode). A single test script would be easier to manage, but multiple test scripts let you provide custom Configuration settings to each test.
Do you want OneTest Embedded to make some basic assumptions about test harness and test stub generation? If so, use Typical Mode; if not, use Expert Mode.
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.
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 CodeCoverage.ads and creates a test for every function within it.
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.