Transcript
Page 1: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Software TestingWhite Box Testing

Page 2: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Agenda

• What is White Box Testing

• Correctness Tests and Path Coverage

• Correctness Tests and Line Coverage

• McCabe Cyclomatic Complexity

• Software Qualification and Reusability Testing

2

Page 3: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Test

Mappin

g

3

Test classificationMcCall Req. Model

White Box Testing

Black Box Testing

Output Correctness Tests +

Documentation Tests +

Availability Tests +

Data Processing and Calculation Correctness +

Software Qualification Tests +

Reliability Tests +

Stress Tests +

Software System Security Tests +

Training Usability Tests +

Operational Usability Tests +

Maintainability Tests + +

Flexibility Tests +

Testability Tests +

Portability Tests +

Reusability Tests +

Software Interoperability Tests +

Equipment Interoperability Tests +

Page 4: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

White Box Testing – Data Processing and Calculation Correctness

Data processing and calculation correctness tests

• Every operation in the sequence created by each test case (path) must be tested

• Done to verify whether processing operations and their sequences were programmed correctly

4

Page 5: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

White Box Testing – S/W Qualification

Software Qualification Tests

• Examine software code including comments

• Comply with the coding standard and work instructions

5

Page 6: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

White Box Testing – Maintainability

Maintainability Tests

• Check special features

• Installed for detection of causes of failure

• Modules to support software adaptation

• Modules to support software improvements

6

Page 7: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

White Box Testing – Reusability

Reusability Tests

• Extent of reuse software integrated in the software

• Adaptations performed to make the reusable component work with the project

7

Page 8: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

• Check data processing for each test case

• Coverage

Path Coverage: Test cases should cover all paths.

Coverage is the percentage of paths covered from the

total

Line Coverage: Test all program code lines. Coverage is

the percentage of lines covered.

Data Processing & Calculation Correctness

8

Page 9: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Path Coverage

9IF – THEN - ELSE

LOOP

Paths are created in a program whenever we use looping

statements or conditional statements

Page 10: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

• Test completeness is the percentage of paths

executed during the test.

• Sometimes impractical to test all paths.

• Example:

Imagine a program with 10 conditional statements with

two options = 1024 different paths.

25-50 lines of code has 1024 test cases

Path Coverage

10

Page 11: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

• Every line of code be executed at least once during

the process of testing.

• Completeness of line testing is the percentage of

lines executed during tests.

Line Coverage

11

Page 12: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Path coverage using flowchart

12

1. Charge min fare

2. DIST3 4

5. WAIT

8. SUIT

6 7

910

11. Print Receipt

D > 1000 D <= 1000

W > 3 W <= 3

S > 1 S <= 1

Page 13: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Path coverage using flowchart

13

Test Case Path 2.

Dist5.

Wait 8. Suit

1 1-2-3-5-6-8-9-11 T T T

2 1-2-3-5-6-8-10-11 T T F

3 1-2-3-5-7-8-9-11 T F T

4 1-2-3-5-7-8-10-11 T F F

5 1-2-4-5-6-8-9-11 F T T

6 1-2-4-5-6-8-10-11 F T F

7 1-2-4-5-7-8-9-11 F F T

8 1-2-4-5-7-8-10-11 F F F

x = No. of decision elementsNo. of Paths = 2x (Max)

Page 14: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Line coverage using flow graph

14

1

2

3 4

6 7

5

8

9 10

11

Page 15: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Line coverage using flow graph

15

Test Case Path

1 1-2-3-5-6-8-9-11

2 1-2-4-5-7-8-10-11

Page 16: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Proportion of Test Cases

16

Line Coverage Path Coverage

2 8

1 : 4For each line coverage, I have four paths.

Page 17: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

• Maximum paths needed for full line coverage

• No. of independent paths needed

Based on Graph Theory

Graph Elements

N is the Number of Nodes

E is the Number of Edges

P is the Number of Decision Elements (2 arrows leaving the element)

Formula

V(G) = E - N + 2

V(G) = P + 1

McCabe’s Cyclomatic Complexity

17

For example

V(G) = 13-11+2 = 4 V(G) = 3+1 = 4

Page 18: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Definition

Any path on the program flow graph that includes at least one edge

that is not included in any of the former independent paths

It is defined in reference to the previous independent paths gathered

Independent Path

18

Path Edges addedNo. of edges

added

1-2-3-5-6-8-9-111-2, 2-3, 3-5, 5-6, 6-8, 8-9, 9-11

7

1-2-4-5-6-8-9-11 2-4, 4-5 2

1-2-3-5-7-8-9-11 5-7, 7-8 2

1-2-3-5-6-8-10-11 8-10,10-11 2

Page 19: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Program Complexity

Based on empirical results (repeated experiments)

Cyclomatic Complexity

19

McCabe CC Program Complexity

< 5Simple, Easy to understand

>=5 && < 10 Not too difficult

> 20 High

> 50 Untestable

Page 20: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

S/W Qualification Testing

Code should be written according to standards – easier to check the

software.

Easier to debug, update the code in maintenance and understand by

new programmers.

Questions

Does the code follow the structure – module size, use of reused code

Is the coding style according to guidelines?

Is the internal program documentation according to the procedure

defined?

Qualification Tests

20

Can be done automatically or manually

If manually, need Code Auditors

Page 21: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

Advantages

Reduces project resource requirements

Improve quality of new systems

Shortens the development time

What is done?

Packages and documentation for reuse conform to standard and

procedures

Reusability Tests

21

Page 22: Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic

White Box Testing

Advantages

• Direct statement-by-statement testing

• Check algorithms are correctly defined and coded

• List of paths / lines that are not executed or covered by test cases

• Measure coding quality

• Adherence to coding standards

Disadvantages

• Vast resources needed

• Cannot test performance in terms of availability (response

time) Reliability Load durability

22

When to use- High Risk Modules- High Cost of Failure


Top Related