Authentication Tests and Disjoint Encryption: a Design Method
TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests...
-
Upload
kayley-braithwaite -
Category
Documents
-
view
223 -
download
0
Transcript of TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests...
TESTS
The V cycle
Specification
Global Design
Detailed Design
Coding
Unit Tests
integration Tests
Validation
V
&
V
• TESTS LEVELS
• TECHNIQUES OF TEST
DYNAMIC VERIFICATION
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()
swap() printf()scanf()
• Fonction à tester :
• void swap(int *p1,int *p2) {• • int aux;• • aux=*p1;• *p1=*p2;• *p2=aux;• }
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);
}
#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() {
int a,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 1printf( "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+14 possibilities
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;
}
The execution sequences
Nbre of iterations Nbre of paths1 32 53 9
10 102520 1 048 57760 > 1,15 1018
Fault sensibility
int scale(short j) {j = j -1; // should be j = j+1j = 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
Designing for Testing
lire I,J;débutCas
cas I = 5 et J < 4alors M = 23;
cas I = 5 et J >= 4alors M = J + 16;
cas (J + 1) < I et I<0alors M = 4I +J;
cas (J + 1) < I et I >= 0 et I /= 5alors M = 5I + 2
cas (J + 1) >= I et J < 2alors M = 2I + 3J - 4;
cas (J + 1) >= I et J>= 2 et I /= 5alors M = 3I +2J –2;
finCasécrire M;
lire I,J;si I <= J + 1
alors K = I + J -1sinon K = 2I + 1
finsisi K >= I+1
alors L = I + 1sinon L = J - 1
finsisi I = 5
alors M = 2L + Ksinon M = L + 2K - 1
finsiécrire M;
• 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.
Classes of equivalence• 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
from cause to effect Graph
• 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
VV
E1
E2
E3
E4
S2
S3
S1
Activity DiagramWRITE DB
MESSAGE M2
X
X
[1st CHARACTER == A]
WRITE DB
MESSAGE M2
X
X
[1st CHARACTER == B]
WRITE DB
MESSAGE M2
X
X
[1st CHARACTER == C]
MESSAGE M1[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)
FIGURE
OUVERTE FERMEE
SEGMENT MULTI-SEG ELLIPSE
CIRCLE
POLYGONE
TRIANGLE QUADRILATERE …..…..
TRIANGLE
SEGMENT
POINT
Control Graph
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;}
Figure: State Machine diagram of class Client
test of sequences of methods activation
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
Sub-System Level
Triangle
Segment
Mediatheque
Document
Document FicheEmprunt
concern
1..*
Sequence Diagram
leLecteurDeCarte uneSession l_Ecran leClavier uneBanque
debuteSession
[pasCarteCrédit]ejectafficheDemandeCode
recupèreLeCode
contrôleCarte[estVolée]garde
Flow Graph
debuteSession
garde
[pasCarteCrédit] éjecte
afficheDemandeCoderecupèreLeCodecontrôleCarte
[estVolée]
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.