1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement...

16
1 Chapter 22 Chapter 22 Developer Testing Developer Testing

Transcript of 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement...

Page 1: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

11

Chapter 22 Chapter 22 Developer Testing Developer Testing

Page 2: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

22

introductionintroduction Testing is the most popular quality-improvement Testing is the most popular quality-improvement

activityactivity Developers are responsible on performing unit tests, Developers are responsible on performing unit tests,

component tests, and integration tests.component tests, and integration tests. developer testing should probably take 8 to 25% of developer testing should probably take 8 to 25% of

the total project time.the total project time. More advanced testing are performed by specialized More advanced testing are performed by specialized

test personnel, such as beta tests, customer-test personnel, such as beta tests, customer-acceptance tests, performance tests, configuration acceptance tests, performance tests, configuration tests, platform tests, stress tests, usability tests, and so tests, platform tests, stress tests, usability tests, and so on.on.

Page 3: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

33

Testing TypesTesting Types

Unit testingUnit testing is the execution of a complete is the execution of a complete class, routine, or small program that has been class, routine, or small program that has been written by single programmer.written by single programmer.

Component testingComponent testing is the execution of a class, is the execution of a class, package, small program, or other program package, small program, or other program element that involves the work of multiple element that involves the work of multiple programmers or programming teams.programmers or programming teams.

Page 4: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

44

Testing TypesTesting Types .. .. continuecontinue

Integration testingIntegration testing is the combined execution is the combined execution of two or more classes, packages, components, of two or more classes, packages, components, subsystems that have been created by multiple subsystems that have been created by multiple programmers or programming teams.programmers or programming teams.

Regression testingRegression testing is the repetition of is the repetition of previously executed test cases for the purpose previously executed test cases for the purpose of finding defects in software that previously of finding defects in software that previously passed the same set of tests.passed the same set of tests.

Page 5: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

55

Testing TypesTesting Types .. .. continuecontinue

System testingSystem testing is the execution of the software is the execution of the software in its final configuration, including integration in its final configuration, including integration with other software and hardware systems. It with other software and hardware systems. It tests for security, performance, resource loss, tests for security, performance, resource loss, timing problems, and other issues that can’t be timing problems, and other issues that can’t be tested at lower levels of integration.tested at lower levels of integration.

Page 6: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

66

Testing CategoryTesting Category

Testing is broken into two broad categories: Testing is broken into two broad categories: black box testing and black box testing and white box (or glass box) testing.white box (or glass box) testing.

Page 7: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

77

Black box testingBlack box testing

refers to tests in which the tester cannot see the refers to tests in which the tester cannot see the inner workings of the item being tested. inner workings of the item being tested.

does not apply when you test code that you does not apply when you test code that you have written!have written!

Page 8: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

88

White box testingWhite box testing

refers to tests in which the tester is aware of refers to tests in which the tester is aware of the inner workings of the item being tested.the inner workings of the item being tested.

This is the kind of testing that developer use to This is the kind of testing that developer use to test his own code.test his own code.

Page 9: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

99

Testing and DebuggingTesting and Debugging

Testing and Debugging are two different Testing and Debugging are two different phasesphases

Testing is a means of detecting errors. Testing is a means of detecting errors. Debugging is a means of diagnosing and Debugging is a means of diagnosing and

correcting the root causes of errors that have correcting the root causes of errors that have already been detected. already been detected.

Page 10: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

1010

Testing during construction Testing during construction

During construction, programmer who write a During construction, programmer who write a routine or class, must check it mentally. thenroutine or class, must check it mentally. then

Programmer must review it or test it.Programmer must review it or test it. Programmer should test each unit thoroughly Programmer should test each unit thoroughly

before he combine it with any others. before he combine it with any others. In case of writing several routines, he should In case of writing several routines, he should

test them one at a time.test them one at a time.

Page 11: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

1111

Structured Basis TestingStructured Basis Testing

test each statement in a program at least once.test each statement in a program at least once. The easiest way is to calculate the number of The easiest way is to calculate the number of

paths through the program and then develop paths through the program and then develop the minimum number of test cases that will the minimum number of test cases that will exercise every path through the program.exercise every path through the program.

Page 12: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

1212

Determining the Number of Test Cases Needed forDetermining the Number of Test Cases Needed for Structured Basis TestingStructured Basis Testing

1. Start with 1 for the straight path through the 1. Start with 1 for the straight path through the routine.routine.

2. Add 1 for each of the following keywords, or 2. Add 1 for each of the following keywords, or their equivalents: their equivalents: ifif, , whilewhile, , repeatrepeat, , forfor, , andand, , and and oror..

3. Add 1 for each case in a case statement. If the 3. Add 1 for each case in a case statement. If the case case statement doesn’t have a default case, add statement doesn’t have a default case, add 1 more.1 more.

Page 13: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

1313

Example 1.. Example 1.. how many test cases programmer how many test cases programmer must checkmust check

Statement1;Statement1;

Statement2;Statement2;

if ( x < 10 ) {if ( x < 10 ) {

Statement3;Statement3;

}}

Statement4;Statement4;

Two Test CasedTwo Test Cased

Page 14: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

1414

In this example, you’d need to have the In this example, you’d need to have the following test cases:following test cases: Statements controlled by Statements controlled by if if are executed (x < 10).are executed (x < 10). Statements controlled by Statements controlled by if if aren’t executed (x >= aren’t executed (x >=

10).10).

Page 15: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

1515

Example 2 .. Example 2 .. how many test cases programmer how many test cases programmer must checkmust check

cin>>x; cin>>y; cin>>z;cin>>x; cin>>y; cin>>z;if (x>0)if (x>0)

cout<<“first number is positive\n”;cout<<“first number is positive\n”;else cout<<“first number is Negative\n”;else cout<<“first number is Negative\n”;if (y>0)if (y>0)

cout<<“Second number is positive\n”;cout<<“Second number is positive\n”;else cout<<“first number is Negative\n”;else cout<<“first number is Negative\n”;if(z>0)if(z>0)

cout<< “Third number is zero”;cout<< “Third number is zero”;else cout<<“first number is Negative\n”;else cout<<“first number is Negative\n”;

Page 16: 1 Chapter 22 Developer Testing. 2 introduction Testing is the most popular quality-improvement activity Testing is the most popular quality-improvement.

1616

Example 3 .. Example 3 .. how many test case programmer how many test case programmer must checkmust check

cin>>y;cin>>y;

switch(y)switch(y)

{{

case 7: cout<<“7”; break;case 7: cout<<“7”; break;

case 8: cout<<“8”; break;case 8: cout<<“8”; break;

}}