Updating and Running the Component Test

Through reuse of existing test assets, your testing effort can be significantly reduced.

To reuse test elements:

  1. Select the Test Report tab.

  2. In the Report Window on the left-hand side of the screen, double-click the node Test 2, which is a child node of the node CODE_INT:

  1. On the Test Report tab, left-click the green section header , located at the top of the screen.

You are now looking at the code for the second of the two code_int tests. Since the objective is to execute the while statement where x has a value of 0, reuse this second test block but assign x an initial value of 0 and buffer an expected value of - what? A value of I10.

  1. In the Text Editor, copy all of the lines between Test 2 and End Test -- Test 2, including these two lines:

TEST 2

FAMILY nominal

  ELEMENT

    VAR x,        init = 34      ev = init

    VAR buffer,   init = "",     ev = "I243"

    #code_int(x,buffer);

  END ELEMENT

END TEST -- TEST 2

 

  1. Paste these lines immediately below the last line copied, and then rename the Test block to Test 3. It should look like the following:

END TEST -- TEST 2

 

TEST 3

FAMILY nominal

  ELEMENT

    VAR x,        init = 34      ev = init

    VAR buffer,   init = "",     ev = "I243"

    #code_int(x,buffer);

  END ELEMENT

END TEST -- TEST 3

 

  1. Change the initial value of x to 0 and change the expected value of buffer to I10.

TEST 3

FAMILY nominal

  ELEMENT

    VAR x,        init = 0      ev = init

    VAR buffer,   init = "",     ev = "I10"

    #code_int(x,buffer);

  END ELEMENT

END TEST -- TEST 3

  1. From the File menu, select Save to save your changes to the Unit Testing test script.

  2. From the View window, select Other Windows and Project Window.

  3. From the Window menu, select Close All.

  4. In the Project Browser tab on the right-hand side of the screen, left-click the UmtsCode component testing node and then click the Build toolbar button.

  5. The test has finished executing when the green execution light on the lower right of the UI stops flashing.

You should have now achieved proper code coverage. But were you looking at the Output Window? Why was there a warning?