Loop Coverage :-
Three kinds of loop coverage criteria.
For( I=0; I < global_integer ; I ++ )
{ . . . }
In this case, at least three different values must be given to global_integer, so that the loop undergoes
1.0 iteration,
2.1 iteration
3.2 or more number of iterations
Note: Following is a static loop
For(I=0; I<10; I++) à this loop would not have 100% loop coverage since it cannot undergo 0 iteration and 1 iteration. At any instant only 2 or more iterations are possible. So the loop coverage will be 1/3 i.e. 33.33%.
Examples :-
- Detailed Design :
Function Declaration:
Void simple ( T_INT simple_param );
External Interface:
extern void ext_function ( T_INT param1 ) ;
Design flow:
Initialize global_1 with simple_param
if global_1 is 1 and global_2 is 0, then send global_2 to ext_function
global_2 is 128 only if global_1 is not 1
Header simple,1,1
#include “simple.c”
#include “head.h”
Begin
# T_INT global_1, global_2;
# void simple ( T_INT simple_param );
# extern void ext_function ( T_INT _in param1 ) ;
Define stub sim_c
# void ext_function ( T_INT _in param1 ) ;
End define
Environment MY_ENV
VAR global_1, init = 99, ev = init
VAR global_2, init = 99, ev = init
End Environment
Use MY_ENV
Service simple_1
# T_INT simple_param ;
Test 1
Family nominal
COMMENT This test checks for …………
element
VAR simple_param, init = 1, ev = init
VAR global_1, init = 100, ev = 1
VAR global_2, init = 67, ev = 0
STUB ext_function ( 0 )
#simple( simple_param );
end element
End test
Test 2
Family nominal
COMMENT This test checks for …………
element
VAR simple_param, init = 5, ev = init
VAR global_1, init = 99, ev = 5
VAR global_2, init = 67, ev = 128
#simple( simple_param );
end element
End test
End service
Example :-
2.
Detailed Design:
Function Declaration:
Void simple ( T_INT simple_param );
External Interface:
extern void ext_function ( T_INT param1,
T_INT * param2 ) ;
Design flow:
Initialize all global data to 0.
Get external global data corresponding to the value of simple_param
Send text “Attol” to output if global_1 is within 2**10 and simple_param is 2
Send text “Attol” to output if global_2 is larger than 12
Analysis
The condition-decision is of the form (A and B ) or C
So Required MCDC test cases are (A, B, C )
T T F
T F F
F T F
F T T
Apart from MCDC cases, if necessary tests are to be carried out for checking Boundary conditions.
Consider global_1 <= 1023
This condition has to be tested with values of global_1 for 1023, 1023- and 1023+ i.e. global_1 should get…
1.1023 à checking on the limit
2.Less than 1023 à checking below the limit
3.Greater than 1023 à checking above the limit
… similarly 2 cases for global_2 < 12
Begin
# T_INT global_1, global_2;
# void simple ( T_INT simple_param );
# extern void ext_function ( T_INT _in param1, _inout param2 ) ;
Define stub sim_c
# void ext_function ( T_INT _in param1 ,
# T_INT _inout *param2 );
End define
…
element
Var simple_param, init = 2, ev = init
Var global_1, init = 99, ev = 1023
Var global_2, init = 67, ev = 11
Stub ext_function ( simple_param, (0,1023) )
Stub ext_function ( 2 , (0,11) )
#simple( simple_param );
End element
………….
ATTOL Jargons:-
ATTOL LANGUAGE
The ATTOL LANGUAGE is a test description language. It enables you to structure FAMILIES, SERVICE BLOCKS, TEST BLOCKS and ELEMENT BLOCKS, and describe the state of variables before and after each test.
ATTOL TEST PLAN GENERATOR
The TEST PLAN GENERATOR is one of the components of ATTOL.
It automatically generates a TEST PLAN template from a source file in the native language.
ATTOL UNITEST PREPROCESSOR
The ATTOL UNITEST PREPROCESSOR is a component of ATTOL. It analyzes a TEST PLAN written in ATTOL language, and generates a test program in C (or C++ or ADA ) and a TABLE OF CORRESPONDENCE FILE.
ATTOL RUNTIME
ATTOL RUNTIME is a component of ATTOL. It is a library of native functions which are linked to the test program and which enable the TRACE FILE to be generated when the tests are executed.
TRACE FILE
This file is generated by ATTOL RUNTIME and contains the results obtained from execution of the tests. It is provided to the ATTOL UNITEST POSTPROCESSOR and is identified by extensions “.rio” or “.rio2” (“.ri2” in DOS and OS2).
TABLE OF CORRESPONDENCE FILE
This file contains the list of the expected variable states at the end of the test runs. It is generated by the ATTOL UNITEST PREPROCESSOR and is identified by the extension “.tdc”.
ATTOL UNITEST POSTPROCESSOR
The ATTOL UNITEST POSTPROCESSOR is one of the components of ATTOL. It compares the TRACE FILE with the TABLE OF CORRESPONDENCE FILE and generates a TEST REPORT which contains a diagnostic for each test.
TEST REPORT
This file contains the final diagnostic for tests executed with ATTOL.
This file is generated by the ATTOL UNITEST POSTPROCESSOR and is identified by the extension “.ro”.
Permalink
How can we test static variable and static function in rtrt????
Permalink
Procedure for testing static variables or static function is same as that for any other extern class variable. Can you please describe the error that you are facing ?
Permalink
int main()
{
static int i;
if(i>15)
{
printf(“print i=”,%d);
}
else{}
}
Can you please help me to write unit testing test cases in rtrt.
how exactly this program works..please explain..
Permalink
For the first time else part will be covered, since by default the value of I is zero as it is static and you need to call the function 15 times to test if part. Use for loop for calling function.