How to create project for TP:
download source code files from google drive
rename if required (if filename changed during download)
keep downloaded source code files in some folder
create DEV C++ project in same folder
add these source code files to project (right click on project and choose "add to project" option
#include <stdio.h>
int add (int a, int b);
int main()
{
int s;
int a,b;
//TC #1
a=10;
b=10;
s=add(a,b);
printf("Tc 1: sum is %d\n", s);
//TC #2
a=-10;
b=5;
s=add(a,b);
printf("Tc 2: sum is %d\n", s);
//TC #3
a=-5;
b=10;
s=add(a,b);
printf("Tc 3: sum is %d\n", s);
//TC #4
a=0;
b=0;
s=add(a,b);
printf("Tc 4: sum is %d\n", s);
//TC #5
a=-10;
b=-5;
s=add(a,b);
printf("Tc 5: sum is %d\n", s);
return 0;
}
int add (int a, int b)
{
return a+b;
}
HLR: add two 32 bit integers and return the sum.
design: software arch
function name: add
inputs:
1. a (32 bit int) [-2147483648 to +2147483647]
2. b (32 bit int) [-2147483648 to +2147483647]
outputs:
1. return value (32 bit int)
LLR: The function add() shall return sum of a and b.
------------------
1. understand functionality in the requirement
2. identify inputs, its datatypes and ranges
3. identify outputs and its data types
4. write min no of test cases to identify all errors in the code/req
i/p i/p o/p (expected value as per req)
-------------------------------------------------
Tc # a b exp o/p act o/p
-------------------------------------------------
1. 10 10 20 20 PASS normal range testing
2. -10 5 -5 -5 PASS
3. -5 10 5 5 PASS
4. 0 0 0 0 PASS
5. -10 -5 -15 -15 PASS
6. +2147483648 robustness testing
-------------------------------------------------
i/ps: req/design/SC/EOC
verification cases
verification procedures
verification results
software verification cases and procedures
software verification results
Requirements based testing (RBT) - only allowed
structured based testing - not allowed as per DO-178B
safety critical system
subject matter expert (SME)
review
exhaustive testing - practically impossible
a - 1,2,3,4
b - 1,2,3
11
12
21
22
howmany TCs? 10
what r those values?
test case design techniques:
1. equivalence class partitioning
2. boundary value analysis
3. modified condition/decision coverage testing (MC/DC)
HLR - HLR review
S/W arch + LLR - design review
SC - SC review
EOC - EOC review
--------------
RBT testing - TC/TP/TR review
-------------10 req - 1000 TC
Analysis
1.RBTCA - requirements based test coverage analysis 100%
2.SCA - structural coverage analysis
statement coverage 100%
decision coverage 100%
MC/DC 100%
RBTCA and SCA review
A && B ==> false
host based testing
target based testing
Z = A && B; ==> NO OF CONDITIONS + 1 ==> 3 TC
MC/DC ==> INDEPENDENT TESTING
AB Z
00 0
01 0
10 0
11 1
AND GATE ==> 00 NOT REQUIRED, 11 MUST
----------------
Z = A || B; ==> NO OF CONDITIONS + 1 ==> 3 TC
MC/DC ==> INDEPENDENT TESTING
AB Z
00 0
01 1
10 1
11 1
OR GATE ==> 11 NOT REQUIRED, 00 MUST
Z = A && B && C; ==> 4 TC
ABC Z
000 0
001 0
010 0
011 0
100 0
101 0
110 0
111 1
Z = A && B || C; ==> 4 TC
ABC Z
000 0
001 1
010 0
011 1
100 0
101 1
110 1
111 1
Z = A && B || C && D; ==> 5 TC
ABCD Z ==>A(0100,1100), B(1001,1101), C
0000 0
0001 0
0010 0
0011 1
0100 0
0101 0
0110 0
0111 1
1000 0
1001 0
1010 0
1011 1
1100 1
1101 1
1110 1
1111 1
Z = A && B || C && D; ==> 5 TC
ABCD Z
0101 0
1001 0
1101 1
1011 1
1010 0
Z = A || B || C && D; ==> 5 TC
ABCD Z
0001 0
0010 0
0011 1
0110 1
1010 1
Z = A || B && C || D; ==> 5 TC
ABCD Z
0010 0
0100 0
0110 1
1100 1
0101 1
Z = A || B || C || D; ==> 5 TC
ABCD Z
0000 0
1000 1
0100 1
0010 1
0001 1
Z = A || B && C || D; ==> 5 TC
ABCD Z
0110 1
0010 0
0100 0
1100 1
0101 1
testing:
c = a+b;
a ==> int ==> 0 to 255
b ==> int ==> 0 to 255
c ==>
a b c
1 1 2
1 2 3
2 1 3
2 2 4
understand requirement
identify inputs and outputs ==> datatype, range(depends memory allocation)
exchaustive testing impossible.
sample based testing
howmany test cases? 10
what values? -128, -127, 0, 9, 10, 11, 12 , 65, 126, 127
end of testing?
TEST COVERAGE ANALYSIS (TCA)
RBTCA ==> REQUIREMENT BASED TEST COVERAGE ANALYSIS (requirements coverage analysis)
HLR RBTCA
LLR RBTCA
every LLR is tested or not
every LLR tested with both normal range and robustness test case or not
SCA ==> STRUCTURAL COVERAGE ANALYSIS (code coverage analysis)
STATEMENT COVERAGE
DECISION COVERAGE
MC/DC
CONTROL COUPLING / DATA COUPLING (CC/DC) COVERAGE
10 requirements ==> 100 test cases
LOW LEVEL TESTING (LLT) ==> LLR
SOFTWARE INTEGRATION TESTING (SIT) ==> S/W ARCH
HARDWARE/SOFTWARE INTEGRATION TESTING (HSIT) ==> HLR
test case design techniques:
equivalence class partitioning (ECP)
Boundary Value Analysis (BVA)
modified condition/decision coverage MC/DC testing
---------------------------------------------------------
why verification? testing?
identify and report errors introduced by developers during software development processes.
Requirement:
If the speed of aircraft exceeds 50 knots, it should execute function x and
if the speed of aircraft exceeds 100 knots, it should execute function y.
speed of aircraft (50 to 100] ==> function x
> 100 ==> function y
(A&&(!A||B))||(C||(!C&&D))
0 1 0 0 1 1 ==>
c1 ==> A
c2 ==> !A
c3 ==> B
c4 ==> C
c5 ==> !C
c6 ==> D
(A||B) && (A||C)
0 1 0 1 ==> 1
0 1 0 0 ==> 0
0 0 0 1 ==> 0
---------------------------------------------
!A && B ==> c1 && c2
c1 ==> !A
c2 ==> B
c1 c2
1 1 1
1 0 0
0 1 0
-----------------
A B ==>
0 1 ==> 1
0 0 ==> 0
1 0 ==> 0
tuning button, volume buttom, power button ==> radio ==> power light, audio (
tuning button, volume buttom, power button ==>M1, M2, M3, M4,M5 ==> power light, audio (intermidiate i/p, o/p)
RBT ==> Requirement Based Testing
LLT/SSIT ==> white box testing
HSIT ==> black box testing
inputs ==> parameters/variables used for calculation or decisions/conditions
outputs ==> parameters/variables updated in calculations or return values
ECP ==> relational/comparison (input specific)
BVA ==> relational/comparison (input specific) - functional boundaries
MC/DC ==> logical equation [and gate, or gate]
min possible test cases ==> but most possible errors
CAS (float) [functional range [59.2484 to 296.242]
CAS > 100
CAS: 99.9 100.0 100.1
Pressure_Altitude: 19999.5 20000.0 20000.5
Flight_time_since_takeoff: 509.5 510.0 510.5
11
10
01
00,01,10
LLR1 ==> The function sum() shall add and return inputs a and b.
a,b ==> 32 bit signed integers (-2147483648 to +2147483647) - inputs
return value (addition of a and b) - 32 bit signed integer - output
a b return_value(exp o/p) Act o/p
------------------------------------------------
10 20 30 30 ==> pass
-10 -20 -30 -30 ==> pass
0 0 0
-20 10 -10
10 -20 -10
with above 5 test cases passed, can we tell software is 100% correct? No, because we have not done exhaustive testing.
1 2 3
1 2 3 4
1-1,2,3,4
2-1,2,3,4
3-1,2,3,4 ==> 12 test cases
600 years
exhaustive testing is impossible.
sample based test cases:
howmany TC?
what values we have to choose?
test case design techniques:
equivalence class partitioning ECP
boundary value analysis BVA
modified condition/decision coverage MC/DC
Requirements based testing RBT
Structural based testing - avoid
if int size is 4 bytes
signed range ==> -2147483648 to +2147483647
unsigned range ==> 0 to 4294967295
int a;
unsigned int b;
verification process: A3 to A7 (40 objectives)
i/p ==> System Requirements
Requirements ==> SRD (HLR) A-3 (7)
Design ==> DD (Software Architecture + LLR) A-4 (13)
Coding ==> Source Code A-5 (7)
Integration ==> EOC A-6 (5)
o/p ==> 1. SVCP 2. SVR A-7 (8)
verification activities:
review
testing
analysis
Testing methods/levels of testing:
low level testing LLT or unit testing UT ==> LLR
software integration testing SIT or SSIT ==> S/W Arch
hardware software integration testing HSIT ==> HLR (high level testing HLT)
LLT/UT, SSIT/SIT
Testing Process:
requirements ==> TC ==> TP ==> execute TP on EOC ==> TR
TCA ==> RBTCA + SCA
TCA ==> test coverage analysis
RBTCA ==> requirements based test coverage analysis
SCA ==> structural coverage analysis
verification process outputs:
TC/TP ==> SVCP
TR ==> SVR
test case design techniques:
equivalence class partitioning ECP
boundary value analysis BVA
modified condition/decision coverage MC/DC
normal range test cases + robustness test cases
end of testing check by TCA (RBTCA + SCA 100%)
understand requirement
find i/ps and o/ps, types, ranges (all i/ps or o/ps must be variables)
i/ps - variables which are used in algorithm or calculations.
o/ps - variables which are updated
REQ1: If a>10, then set b to TRUE; otherwise False, if a in within the range; otherwise display "invalid input" error message.
Note: a is integer type. Range (-128 to 127)
b is Boolean type. Range: True, False
inputs:
a (int)
outputs:
b (boolean)
error message (string)
test cases:
----------------------------------------------
a b error message
-129 n/a invalid input ==> invalid test case (robustness test case) pass
-128 false n/a ==> normal range test case pass
-127 false n/a pass
0 false n/a pass
9 false n/a pass
10 false n/a pass
11 true n/a pass
12 true n/a pass
69 true n/a pass
126 true n/a pass
127 true n/a pass
128 n/a invalid input ==> invalid test case (robustness test cases) pass
--------------------------------------------
equivalence class partitioning + boundary value analysis
---------------------------------------------
[-128 to 127]
[-128 to 10] [11 to 127]
false true
5 ==> false
20 ==> true
REQ1: If a>10, then set b to TRUE; otherwise False, if a in within the range; otherwise display "invalid input" error message.
-129 -128 -127 0 9 10 11 12 65 126 127 128
i f f f f f t t t t t i
min-1, min, min+1, mid, max-1, max, max+1
sample based test cases:
howmany TC? 12
what values we have to choose? -129,-128,-127,0,9,10,11,12,69,126,127,128
----------------------
-129
-128
-127
0
9
10
11
12
69
126
127
128
--------------
testing/verification purpose:
find and report errors introduced during development. (code + requirements + design)
provide confidence that system is working as per requirements.
//REQ1: If a>10, then set b to TRUE; otherwise False, if a in within the range;
//otherwise display "invalid input" error message. Note: a is integer type. Range (-128 to 127)
#include <stdio.h>
int main()
{
enum boolean_type {False, True};
typedef enum boolean_type bool;
int a;
bool b;
a=127;
if(a>=-128 && a<=127)
{
if(a>10)
{
b=True;
}
else
{
b=False;
}
printf("b=%d\n",b);
}
else
{
printf("invalid input\n");
}
return 0;
}
REQ1: If a>10 and a<20, then set b to 20; otherwise 0.
Note: a is integer type. Range (-128 to 127)
b is integer type. Range (-128 to 127)
C1 ==> a>10
C2 ==> a<20
M ==> C1 && C2
C1 C2 M
1 1 1 tc7,8,9,10,11
0 1 0 TC2,3,4,5,6
1 0 0 tc12,13,14,15
[-128 to 10] [11 to 19] [20 to 127]
0 20 0
-129, -128, -127, 0, 9, 10, 11
12, 15, 18,
19,20,21, 69, 126, 127, 128
a b
-----------------------
-129 ???? robustness
-128 0
-127 0
0 0
9 0
10 0
11 20
12 20
15 20
18 20
19 20
20 0
21 0
69 0
126 0
127 0
128 ???? robustness
REQ1: If a==0, then set b to TRUE; otherwise FALSE.
Note: a is integer type. Range (-128 to 127)
b is Boolean type. Range: True, False
[-128 to -1] [0] [1 to 127]
false true false
-129, -128, -127, -69, -2, -1, 0
1,2,69,126,127,128
REQ1: Let's consider the behavior of tickets in the Flight reservation application, while booking a new flight.
Ticket values 1 to 10 are considered valid & ticket is booked. While value 11 to 99 are considered invalid for reservation and error message will appear, "Only ten tickets may be ordered at one time."
Note: Ticket Value is an integer. (Range: 0 to 500).
inputs:
ticket value - int - [0 to 500]
output:
ticked booked status
error message
[0] [1 to 10] [11 to 99] [100 to 500]
???? valid & booked error message ????
logical equation ==> AND gate - OR gate
a,b,c
a>b && a>c ==> a is bigger
A,B
bool A,B;
A = true;
B = false;
Z = A && B;
AB Z
00 0
01 0
10 0
11 1
Z = A && B&&C;
ABC Z
000 0
001 0
010 0
011 0
100 0
101 0
110 0
111 1
Z = A && B&&C&&D; ==> 16 test cases
Z = A && B&&C&&D&&E&&F&&G&&H&&I&&J; ==> 10 conditions ==> 1024 test cases
MC/DC ==> no of conditions + 1 ==> 10 conditions ==> 11 test cases
MC/DC definition:
every condition in the decision must be tested independently.
Z = A && B;
AB Z
01 0
10 0
11 1
Z = A && B&&C;
ABC Z
011 0 - A
101 0 - B
110 0 - C
111 1 - A,B, C
Z = (A && B)||C;
ABC Z
010 0 - A
100 0 - C,B
101 1 - C
110 1 - B,A
REQ1: Z = A && B
AB Z
------
01 0
10 0
11 1
for AND gate 00 is not required, 11 is must.
REQ2: Z = A || B
AB Z
------
00 0
01 1
10 1
for OR gate 11 is not required, 00 is must.
REQ3: Z = A xor B
all 4 combinations are required to test XOR gate.
REQ1: z = (A && B) && C
ABC Z
111 1
011 0
101 0
110 0
REQ2: z = A || (B && C)
ABC Z
011 1
001 0
010 0
110 1
REQ3: z = (A && B) || C
ABC Z
110 1
010 0
100 0
101 1
REQ4: z = (A || B) || C
ABC Z
000 0
100 1
010 1
001 1
REQ10: Z = (A && B) || (C && D)
ABCD Z
1101 1
0101 0
1001 0
0111 1
0110 0
REQ12: Z = (A && B) && (C || D)
ABCD Z
1110 1
0110 0
1010 0
1100 0
1101 1
inputs vs conditions:
---------------------------
REQ1: When a>10 && b<20 || c==30, then set Z to TRUE; otherwise FALSE.
i/ps ==> a,b,c
conditions ==> a>10, b<20, c==30
MC/DC TCs ==> 3+1 ==> 4
ECP, BVA, MC/DC
c1 ==> a>10
c2 ==> b<20
c3 ==> c==30
c1 && c2 || c3
c1 c2 c3 Z
1 1 0 1
0 1 0 0
1 0 0 0
1 0 1 1
test cases:
a b c Z
11 19 29 1
9 19 31 0
11 21 31 0
11 20 30 1
10 20 30 1
REQ2: When a>10 && b<20 || a==5, then set Z to TRUE; otherwise FALSE.
i/ps ==> a,b
conditions ==> a>10, b<20, a==5
MC/DC TCs ==> 3+1 ==> 4
c1 ==> a>10
c2 ==> b<20
c3 ==> a==5
c1&&c2||c3
c1 c2 c3
1 1 0 1
0 1 0 0
1 0 0 0
0 1 1 1
==> this combination is not possible because c1 and c3 are dependent on each other via same variable 'a', we cant drive c1 as true and c3 as true at same time.
a b z
11 19 1
9 19 0
11 20 0
5 19 1
10 21 0
4 21 0
6 21 0
REQ1: The Navigation Source symbol shall be displayed as follows:
If SELECTED_NAV_SRC = FMS1 or FMS2 then
Display Navigation Source symbol
Else
Do not display Navigation Source symbol
Endif
Note: SELECTED_NAV_SRC is a six state parameter. (enum)
Defined states for the input parameter SELECTED_NAV_SRC are:
ILS1, ILS2, FMS1, FMS2, VOR1, VOR2
inputs:
SELECTED_NAV_SRC
outputs:
navigation source symbol display status
logical equation ==> (SELECTED_NAV_SRC == FMS1) || (SELECTED_NAV_SRC == FMS2)
c1 ==> SELECTED_NAV_SRC == FMS1
c2 ==> SELECTED_NAV_SRC == FMS2
c1||c2
c1 c2
0 0 0 Tc3,Tc4,Tc5,Tc6
0 1 1 Tc2
1 0 1 TC1
TC# SELECTED_NAV_SRC navigation source symbol display status
1 FMS1 display navigation source symbol
2. FMS2 display navigation source symbol
3 ILS1 Do not display Navigation Source symbol
4 ILS2 Do not display Navigation Source symbol
5 VOR1 Do not display Navigation Source symbol
6 VOR2 Do not display Navigation Source symbol
----------------------------
TC# MAG/TRUE SELECT SWITCH MAGNETIC HEADING status TRUE HEADING status | MAG/TRUE REFERENCE
1 MAG INVALID VALID TRU
2 MAG VALID VALID MAG
3 MAG INVALID INVALID MAG
4 TRU INVALID FUNCTIONAL_TEST TRU
5 TRU FUNCTIONAL_TEST NO_COMPUTED_DATA TRU
6 MAG NO_COMPUTED_DATA NO_COMPUTED_DATA MAG
logical equation ==> MAG/TRUE SELECT SWITCH is TRU or (MAGNETIC HEADING status is not valid and TRUE HEADING status is valid)
c1 ==> MAG/TRUE SELECT SWITCH == TRU
c2 ==> MAGNETIC HEADING status == INVALID
c3 ==> TRUE HEADING status == VALID
c1 || (c2 && c3)
c1 c2 c3
--------
0 1 1 1 TC1
0 0 1 0 TC2
0 1 0 0 TC3
1 1 0 1 TC4
REQ2:
If MAG/TRUE SELECT SWITCH is TRU or (MAGNETIC HEADING status is not valid and TRUE HEADING status is valid), then MAG/TRUE REFERENCE shall be TRU; otherwise MAG.
Note:
1) MAG/TRUE SELECT SWITCH is a two state parameter. (enum)
Defined states for the input parameter MAG/TRUE SELECT SWITCH are:
MAG
TRU
2) MAGNETIC HEADING status and TRUE HEADING status are a four state parameter. (enum)
Defined states for the input parameter MAGNETIC HEADING status and TRUE HEADING status are:
VALID
FUNCTIONAL_TEST
NO_COMPUTED_DATA
INVALID
inputs:
MAG/TRUE SELECT SWITCH
MAGNETIC HEADING status
TRUE HEADING status
outputs:
MAG/TRUE REFERENCE
---------------------------------------------
d = sqrt ((x2-x1)^2 + (y2-y1)^2)
x1 x2 y1 y2 d
----------------------------------
0.3 0.2 0.6 0.674
A --> B
--> C
Assignment Requirement:
The Radio Altitude MODULE shall set "Radio Altitude Too Low Condition Enabled" to 'True' when any of the following conditions is met, otherwise set to 'False':
Ralt is 'Degraded', 'No Go' or 'Invalid'
Ralt is 'Info' or 'Go' and Radio Altitude is less than or equal to 150.0 feet
Tracking Mode is 'Silence'
Notes:
Ralt is of type Equipment status(which is an enum) - Degraded, No Go, Invalid, Info, Go
Tracking Mode is of type Radalt Tracking Mode Data (Which is an enum) - Silence, Others
Functional Range of Radio Altitude is “-8192.875” to “8192.875" (resolution --> 0.5)
Requirement: REQ4.5.1
ALIGNED WITH RWYGC36 shall be set as follows:
If (ABS(Mag Heading - Selected Course) < 10 degrees) then
ALIGNED WITH RWY = Set
Else
ALIGNED WITH RWY = Reset
Endif
TC1 TC2 TC3 TC4 TC5 TC6
Mag Heading 30 30 20 11 20 9
Selected Course 20 19 11 20 30 20
ALIGNED WITH RWY Reset Reset Set Set Reset Reset
Write MC/DC for a&&(b||c&&d||e)&&f
abcdef o/p
100101 0
101101 1
100001 0
110001 1
010001 0
110000 0
110011 1
Write MC/DC test cases:
Z = A && B;
Z = A || B;
Z = A && B && C;
Z = A && B || C;
Z = A || B && C;
Z = A || B || C;
Z = A && (B || C);
Z = (A || B) && C;
Z = A && B && C && D;
Z = A || B || C || D;
Z = A && B || C && D;
Z = A && (B || C) && D;
-------------------
Z = A && B || A && C;
Z = A && B || !A && C;
Z = A && B || !C
#include <stdio.h>
int main()
{
float a,b;
a = 2.564535;
b = 2.564535;
if(a==b)
{
printf("same\n");
}
else
{
printf("different");
}
return 0;
}
//real numbers should not be used with == and != relational operators
//for testing real numbers outputs, we have to use tolerance as mentioned in requirements or testing standards.