tests. the v cycle specification global design detailed design coding unit tests integration tests...

47
TESTS

Upload: kayley-braithwaite

Post on 15-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

TESTS

Page 2: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

The V cycle

Specification

Global Design

Detailed Design

Coding

Unit Tests

integration Tests

Validation

V

&

V

Page 3: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

• TESTS LEVELS

• TECHNIQUES OF TEST

DYNAMIC VERIFICATION

Page 4: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

TESTS LEVELS

• UNIT TESTS

• INTEGRATION TESTS

• SYSTEM TESTS ** VALIDATION **

• NON-REGRESSIVE TESTS

Page 5: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

TECHNIQUES OF TESTS • FUNCTIONAL TESTS

• STRUCTURALS TESTS

• ERROR - ORIENTED TESTS

• ROBUSTNESS TESTS

• PERFORMANCE TESTS

Page 6: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

TESTS AND ANALYSIS

• DEFINITION

• TECHNIQUES OF ANALYSIS

• TECHNIQUES OF TESTS

• SELECTION OF RIGHT TECHNIQUES

• TESTING TOOLS

Page 7: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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 "

Page 8: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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

Page 9: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

Example

• informal Specification :

Write a programme which permit to enter the elements of an array, reverse them and display the reversed array.

Page 10: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

Call graph

main()

writeArray() reverseArray() displayArray()

swap() printf()scanf()

Page 11: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

• 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);

}

Page 12: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

#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;}

Page 13: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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]);

}

Page 14: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

#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]);}

Page 15: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

The limitation of testing

• Input space

• execution sequences

• fault sensibility

Page 16: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

• 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

Page 17: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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;}

Page 18: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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;

}

Page 19: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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;

}

Page 20: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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;

}

Page 21: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

The execution sequences

Nbre of iterations Nbre of paths1 32 53 9

10 102520 1 048 57760 > 1,15 1018

Page 22: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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)

Page 23: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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.

Page 24: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

Testing, Why?

• Missing functionalities• Wrong functionalities• Side effects, not wanted interactions• bad performances, real time problems,

deadlock…• Wrong outputs

Page 25: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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;

Page 26: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

• 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.

Page 27: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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

Page 28: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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.

Page 29: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

from cause to effect Graph

VV

E1

E2

E3

E4

S2

S3

S1

Page 30: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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 ! = ….]

Page 31: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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

Page 32: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

• 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.

Page 33: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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)

Page 34: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

FIGURE

OUVERTE FERMEE

SEGMENT MULTI-SEG ELLIPSE

CIRCLE

POLYGONE

TRIANGLE QUADRILATERE …..…..

Page 35: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

TRIANGLE

SEGMENT

POINT

Page 36: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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;}

Page 37: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

Figure: State Machine diagram of class Client

test of sequences of methods activation

Page 38: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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

Page 39: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

Sub-System Level

Triangle

Segment

Mediatheque

Document

Document FicheEmprunt

concern

1..*

Page 40: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

Sequence Diagram

leLecteurDeCarte uneSession l_Ecran leClavier uneBanque

debuteSession

[pasCarteCrédit]ejectafficheDemandeCode

recupèreLeCode

contrôleCarte[estVolée]garde

Page 41: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

Flow Graph

debuteSession

garde

[pasCarteCrédit] éjecte

afficheDemandeCoderecupèreLeCodecontrôleCarte

[estVolée]

Page 42: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

The Test in Object Oriented Programming

• Integration Tests (class diagram => dependance tree- inheritance diagram)

• Techniques– big-bang– bottom-up– top-down

Page 43: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

The Test in Object Oriented Programming

• Application Level (Uses cases)

Page 44: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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

Page 45: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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

Page 46: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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

Page 47: TESTS. The V cycle Specification Global Design Detailed Design Coding Unit Tests integration Tests Validation V&VV&V

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.