470 likes | 885 Views
TESTS. Validation. Specification. Global Design. integration Tests . Detailed Design. Unit Tests. Coding. The V cycle . V & V. DYNAMIC VERIFICATION. TESTS LEVELS TECHNIQUES OF TEST . TESTS LEVELS. UNIT TESTS INTEGRATION TESTS SYSTEM TESTS ** VALIDATION ** NON-REGRESSIVE TESTS .
E N D
Validation Specification Global Design integration Tests Detailed Design Unit Tests Coding The V cycle V & V
DYNAMIC VERIFICATION • TESTS LEVELS • TECHNIQUES OF TEST
TESTS LEVELS • UNIT TESTS • INTEGRATION TESTS • SYSTEM TESTS ** VALIDATION ** • NON-REGRESSIVE TESTS
TECHNIQUES OF TESTS • FUNCTIONAL TESTS • STRUCTURALS TESTS • ERROR - ORIENTED TESTS • ROBUSTNESS TESTS • PERFORMANCE TESTS
TESTS AND ANALYSIS • DEFINITION • TECHNIQUES OF ANALYSIS • TECHNIQUES OF TESTS • SELECTION OF RIGHT TECHNIQUES • TESTING TOOLS
DEFINITION • Software testing is the execution of a system or a component using automatic or manual means in order to verify the software fulfils its specifications or identify the differences between the expected results and the observed results "
Test Case • A test case specify : • the state of the Implementation Under Test (IUT) and its environment before the test • the vector of input variables and the conditions • the expected result • messages, exceptions • values of output variables • the resulting state of the IUT and its environment
Example • informal Specification : Write a programme which permit to enter the elements of an array, reverse them and display the reversed array.
Call graph main() writeArray() reverseArray() displayArray() scanf() printf() swap()
Jeu de test : /* input vector */ a = 3; b = 4; /* output vector */ ra = 4; rb = 3; Boolean oracle(int r1, int p1, int r2, int p2) { return (r1 == p1 && r2 == p2); } • Fonction à tester : • void swap(int *p1,int *p2) { • int aux; • aux=*p1; • *p1=*p2; • *p2=aux; • }
#include <stdio.h> #include "definitions.h" Boolean oracle(int rp1, int pp1, int rp2, int pp2); /* function to test */ void swap(int*p1,int *p2); int main() { inta,b,ra,rb; Boolean resultat; resultat = FALSE; /* input vector */ a = 3; b = 4; /* output vector */ ra = 4; rb = 3; swap(&a, &b); resultat = oracle(a,ra,b,rb); printf("resultat = %s\n", (resultat == TRUE) ? "Test OK":"Error"); #if 1 printf( "a = %d b = %d\n",a,b); printf( " ra = %d rb = %d\n",ra,rb); #endif } Boolean oracle(int r1, int p1, int r2, int p2) { return (r1 == p1 && r2 == p2); } void swap(int *p1,int *p2) { int aux; aux=*p1; *p1=*p2; *p2=aux; }
Function to test : void reverseArray(int t[]) { int i; for(i=0;i<DIM/2;i++) swap(&t[i],&t[DIM-1-i]); } Test Case : /* input vector */ int tab[DIM] ={0,1,2,3,4,5,6}; /* output vector */ int tabInv[DIM] = {6,5,4,3,2,1,0}; Boolean oracle(int t[], int t1[]) { return (t[0] == t1[0] && t[1] == t1[1] && t[2] == t1[2] && t[3] == t1[3] && t[4] == t1[4] && t[5] == t1[5] && t[6] == t1[6]); }
#include <stdio.h> #include "definitions.h" Boolean oracle(int t[], int t1[]); void swap(int *p1,int *p2); /* function to test */ void reverseArray(int t[]); int main() { Boolean resultat = FALSE; /* input vector */ int tab[DIM] ={0,1,2,3,4,5,6}; /* output vector */ int tabInv[DIM] = {6,5,4,3,2,1,0}; reverseArray(tab); resultat = oracle(tabInv, tab); printf("resultat = %s\n", (resultat == TRUE) ? "Test OK":"Error"); } Boolean oracle(int t[], int t1[]) { return (t[0] == t1[0] && t[1] == t1[1] && t[2] == t1[2] && t[3] == t1[3] && t[4] == t1[4] && t[5] == t1[5] && t[6] == t1[6]); } void swap(int *p1,int *p2) { int aux; aux=*p1; *p1=*p2; *p2=aux; } void reverseArray(int t[]) { int i; for(i=0;i<DIM/2;i++) swap(&t[i],&t[DIM-1-i]); }
The limitation of testing • Input space • execution sequences • fault sensibility
Read 3 integer values. These 3 values represent the length of the sides of a triangle. The programme displays a message which establishes that the triangle is isoceles, équilateral or scalene. • If an integer is given in 2 Bytes, it means that there are 6553- possibilities => for 3 integers there are 2,81475E+14possibilities
The execution sequences for (int i=0; i<n; ++i) { if (a.get(i) ==b.get(i)) x[i] = x[i] + 100; else x[i] = x[i] /2; }
The execution sequences • for (int i=0; i<n; ++i) { if (a.get(i) ==b.get(i)) x[i] = x[i] + 100; else x[i] = x[i] /2; }
The execution sequences • for (int i=0; i<n; ++i) { if (a.get(i) ==b.get(i)) x[i] = x[i] + 100; else x[i] = x[i] /2; }
The execution sequences • for (int i=0; i<n; ++i) { if (a.get(i) ==b.get(i)) x[i] = x[i] + 100; else x[i] = x[i] /2; }
Fault sensibility int scale(short j) { j = j -1; // should be j = j+1 j = j/30000; return j; } We suppose that a short integer is coded in 2 bytes (16 bits)
Other limitations • To Test a programme permits to show that there are faults but not their absence • The tests based on an implementation cannot reveal omissions because the absent code cannot be tested • One can never be sure that a test system is without any error.
Testing, Why? • Missing functionalities • Wrong functionalities • Side effects, not wanted interactions • bad performances, real time problems, deadlock… • Wrong outputs
lire I,J; débutCas cas I = 5 et J < 4 alors M = 23; cas I = 5 et J >= 4 alors M = J + 16; cas (J + 1) < I et I<0 alors M = 4I +J; cas (J + 1) < I et I >= 0 et I /= 5 alors M = 5I + 2 cas (J + 1) >= I et J < 2 alors M = 2I + 3J - 4; cas (J + 1) >= I et J>= 2 et I /= 5 alors M = 3I +2J –2; finCas écrire M; lire I,J; si I <= J + 1 alors K = I + J -1 sinon K = 2I + 1 finsi si K >= I+1 alors L = I + 1 sinon L = J - 1 finsi si I = 5 alors M = 2L + K sinon M = L + 2K - 1 finsi écrire M; Designing for Testing
Read 3 integer values. These 3 values represent the length of the sides of a triangle. The programme displays a message which establishes that the triangle is isoceles, équilateral or scalene.
8 valid Classes scalele triangle isoceles triangle (4) équilateral (2) 25 non valid Classes 1 value = 0 3 values = 0 1 negative value flat isoceles triangle 3 values such that the sum of 2 of them < to the third (6) 1 non numeric value (3) 1 missing value (3) flat scalene triangle 1 max value Classes of equivalence
Principe : showing the specification as a graph One define the inputs and outputs One build the graph by means of logic connectors (and, or, non) Example : Be the following specification: Any vehicule identifier must begin by the A, B or C character and having as 2nd character a X. the messages M1 and M2 are provided respectively in case of error on the first or the second character. If the identifier is right, it is put in a database. from cause to effect Graph
from cause to effect Graph E1 S2 E2 V V S3 E3 S1 E4
X X X WRITE DB WRITE DB WRITE DB [1st CHARACTER == B] [1st CHARACTER == C] [1st CHARACTER == A] X X X MESSAGE M2 MESSAGE M2 MESSAGE M2 MESSAGE M1 Activity Diagram [1st CHARACTER ! = ….]
The Test in Object Oriented Programming • Class level • test of methods • “designing for testing” • control graph • data flow graph • test of sequences of methods activation • states transitions diagramme • test of inherited methods • classe diagramme
Read 3 integer values. These 3 values represent the length of the sides of a triangle. The programme displays a message which establishes that the triangle is isoceles, équilateral or scalene.
A test about Testing • Procedural programming • 33 cases of test • Objet Oriented Programming • 58 cases of test (26 are commun to those above,, 32 are due to the OOP)
SEGMENT TRIANGLE FIGURE FERMEE OUVERTE POLYGONE ELLIPSE MULTI-SEG CIRCLE QUADRILATERE ….. …..
TRIANGLE SEGMENT POINT
for (int i=0; i<n; ++i) { if (a.get(i) ==b.get(i)) x[i] = x[i] + 100; else x[i] = x[i] /2; } Control Graph
test of sequences of methods activation Figure:State Machine diagramof class Client
The Test in Object Oriented Programming • Subsystem Level • test of associations, aggregations (class diagram) • multiplicity • creation, deletion • test of sequences (sequence diagram ) • building of a flow graph • test of controlled exceptions
Triangle Segment Mediatheque Document Document FicheEmprunt 1..* concern Sub-System Level
Sequence Diagram leLecteurDeCarte uneSession l_Ecran leClavier uneBanque debuteSession [pasCarteCrédit]eject afficheDemandeCode recupèreLeCode contrôleCarte [estVolée]garde
Flow Graph debuteSession [pasCarteCrédit] éjecte afficheDemandeCode recupèreLeCode contrôleCarte [estVolée] garde
The Test in Object Oriented Programming • Integration Tests (class diagram => dependance tree- inheritance diagram) • Techniques • big-bang • bottom-up • top-down
The Test in Object Oriented Programming • Application Level (Uses cases)
The Test in Object Oriented Programming • The interaction of methods (individually right) of classes et sub-classes could generate errors => These interactions must be systematically tried
The Test in Object Oriented Programming • Omitting the overloading of a method of a super class situated very hight in the hierarchy graph is easy => The test designed for the super classes must be re-executed on each of the sub-classes et designed to be re-used in order to test any of the sub classes
The Test in Object Oriented Programming • The difficulty and complexity of implementing constraints of multiplicity could very easily lead to errorswhen an element is, added, up to dated, deleted. => The implementation of multiplicity should be systematically tried
The Test in Object Oriented Programming • Classes with séquential constraints on methods activation and their clients could have sequencement errors => The required behaviourshould be tested using a model of state machine.