Environment override

Component Testing for C

To provide more flexibility in using environments, you can override the initialization and test specifications in an ENVIRONMENT block for one or more variables, one or more array elements, or one or more fields of a structured variable by using either of the following:

The ENVIRONMENT concept greatly improves test robustness. You can use this approach to group default initialization and test specifications with all the variables that are global to a module under test, allowing you to check that unexpected global variables in tests on a service are indeed not modified.

The following steps are used to handle environments:

This process means that:

Example

The following example illustrates an override of an array element in two tests:

 TEST 1

 FAMILY nominal

 ELEMENT

 VAR histo[0], init = 0, ev = SIZE_IMAGE*SIZE_IMAGE

 #status = compute_histo(x1,y1,x2,y2,histo);

 END ELEMENT

 END TEST

 TEST 2

 FAMILY nominal

 ELEMENT

 ARRAY image, init = {others => {others => 100}}, ev = init

 ARRAY histo[100], init = 0, ev = SIZE_IMAGE*SIZE_IMAGE

 #status = compute_histo(x1,y1,x2,y2,histo);

 END ELEMENT

 END TEST

 

In the first test, only histo[0] has an override. Therefore, all the default tests were generated except for the test on the histo variable, which had its 0 element removed, and a test was generated on histo[1..255].

In the second test, the override is more noticeable; the histo[100] element has been removed to generate two tests: one on histo[0..99], and the other on histo[101..255].