Editing the generated component test for Ada

The Component Testing Wizard analyzed the CodeCoverage  source files and produced a test script called CodeCoverage.ptu. What does this test do?

To edit the generated .ptu script:

  1. In the Project Browser tab on the right-hand side of the screen, open the file CodeCoverage.ptu by double-clicking it.

  2. Maximize the test script window that has just opened, closing the lower Output Window to free up some additional space.

  3. Click the Asset Browser tab on the right-hand side of the screen and select the By File sort method.

On the Asset Browser tab you now see each of the functions listed as a child of the test script CodeCoverage.ptu. Each function requires its own test; all test scripts are stored in the .ptu file. Back on the Project Browser tab, you'll notice that the .ptu file is associated with the source file upon which it was based. The idea is that when you build the MyAdaTest component testing node, you are actually building a test harness comprised of the .ptu file, the original source files and any stubs required for the simulation of as yet undeveloped code. The build process and test execution, as you recall, is managed by the information stored in a Configuration which, in turn, is based on the information stored in a Target Deployment Port.

Component testing scripts for C and Ada are written with a compiler-independent test script API. For detailed information about the script layout, take advantage of the Reference Guide accessible via the Help menu. For the tutorial, only critical script elements will be pointed out.

  1. In the Asset Brower tab, double-click the SIMPLECONDITION function (child node of CodeCoverage.ptu).

Of particular note are the SERVICE blocks in a test script. Each function in the file under test is assigned its own SERVICE block. Each SERVICE block can consist of one or more Test blocks. Each Test block consists of data-driven calls to the function under test.

Here you see the Service block for the CodeCoverage.ptu function SIMPLECONDITION. This is then followed by native Ada language calls (indicated by the # symbol) used to declare the variables X and Ret_SIMPLECONDITION that are passed to the function SIMPLECONDITION.

The variable declarations are followed by an Environment block. The Environment block is used to define input (called init - i.e. initial) and output (called ev - i.e. expected value) values for the variables passed to the function under test. In the Environment block for the SIMPLECONDITION service block, X is initialized to 0 and has an expected value of init - that is, a value of 0, the initial value. Ret_SIMPLECONDITION is initialized to 0 with an expected return value of 0.

The TEST 1 block for SIMPLECONDITION consists of a call to this function.

A return value is expected - referred to as:

#Ret_SIMPLECONDITION:=CODECOVERAGE.SIMPLECONDITION(X);

You now understand the essence of HCL OneTest Embeddedcomponent testing test script for Ada.

For the purposes of performing useful work, the test script needs to be more detailed than it is immediately following generation. You need to create good tests that supply relevant input values and then verify appropriate output values. Rather than writing it yourself, a revised test has been created for you.