MSc Software Testing and Maintenance MSc Prófun og viðhald hugbúnaðar

Similar documents
MSc Software Testing MSc Prófun hugbúnaðar

Lecture 26: Testing. Software Engineering ITCS 3155 Fall Dr. Jamie Payton

What is Structural Testing?

STRUCTURAL TESTING. AKA White Box Testing. Thanks go to Andreas Zeller for allowing incorporation of his materials. F. Tip and M.

Structural Testing. Testing Tactics. Why Structural? Structural white box. Functional black box. Structural white box. Functional black box

STRUCTURAL TESTING. AKA White Box Testing. Thanks go to Andreas Zeller for allowing incorporation of his materials. F. Tip and M.

Introduction to Software Engineering

INTRODUCTION TO SOFTWARE ENGINEERING

Testing Methods: White Box Testing II

White-Box Testing Techniques

Subject Software Testing Structural Testing

Structural Testing. Testing Tactics. Why Structural? Structural white box. Functional black box. Structural white box. Functional black box

Software Testing Fundamentals. Software Testing Techniques. Information Flow in Testing. Testing Objectives

Testing Tactics. Structural Testing. Why Structural? Why Structural? Functional black box. Structural white box. Functional black box

MTAT : Software Testing

Logic Coverage for Source Code

Structural Testing. White Box Testing & Control Flow Analysis

MTAT : Software Testing

Program Testing and Analysis: Manual Testing Prof. Dr. Michael Pradel Software Lab, TU Darmstadt

MTAT : Software Testing

Using the code to measure test adequacy (and derive test cases) Structural Testing

Darshan Institute of Engineering & Technology Unit : 9

Software Testing. Massimo Felici IF

Introduction to Dynamic Analysis

Software Testing Prof. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur. Lecture 13 Path Testing

Verification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80

Overview. State-of-the-Art. Relative cost of error correction. CS 619 Introduction to OO Design and Development. Testing.

Path Testing + Coverage. Chapter 8

Software Testing. Lecturer: Sebastian Coope Ashton Building, Room G.18

Software Testing. 1. Testing is the process of demonstrating that errors are not present.

Aerospace Software Engineering

Software Testing. Software Testing

Testing! Prof. Leon Osterweil! CS 520/620! Spring 2013!

Software Testing for Developer Development Testing. Duvan Luong, Ph.D. Operational Excellence Networks

Promela and SPIN. Mads Dam Dept. Microelectronics and Information Technology Royal Institute of Technology, KTH. Promela and SPIN

ABSTRACT I. INTRODUCTION

Test Case Selection and Adequacy

Introduction au Génie Logiciel Partie3: Test: Static White-Box Test

CS 520 Theory and Practice of Software Engineering Fall 2018

Structural Testing. (c) 2007 Mauro Pezzè & Michal Young Ch 12, slide 1

UNIT-2. This unit gives an in depth overview of path testing and its applications. At the end of this unit, the student will be able to:

Testing: Coverage and Structural Coverage

[IT6004-SOFTWARE TESTING] UNIT 2

A Method for Automated Unit Testing of C Programs

1 Black Box Test Data Generation Techniques

Data-Flow Analysis Foundations

(See related materials in textbook.) CSE 435: Software Engineering (slides adapted from Ghezzi et al & Stirewalt

An Empirical Evaluation of Test Adequacy Criteria for Event-Driven Programs

Lecture 14: Chapter 18!

c. Typically results in an intractably large set of test cases even for small programs

Topics in Software Testing

7. Testing and Debugging Concurrent Programs

SFWR ENG 3S03: Software Testing

Software Engineering Software Testing Techniques

6. Test-Adequacy. Assessment Using Control Flow and Data Flow. Andrea Polini

Test Case Specifications and Test adequacy. Research Methods - Barbara Russo SwSE - Software and Systems Engineering

CSCI 5654 (Fall 2013): Network Simplex Algorithm for Transshipment Problems.

Lecture 18: Structure-based Testing

Software Testing TEST CASE SELECTION AND ADEQUECY TEST EXECUTION

Facts About Testing. Cost/benefit. Reveal faults. Bottom-up. Testing takes more than 50% of the total cost of software development

Software Testing part II (white box) Lecturer: Giuseppe Santucci

Testing: Coverage and Structural Coverage

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Unit Testing. Emina Torlak

CMPT 473 Software Quality Assurance. Graph Coverage. Nick Sumner

A METRIC BASED EVALUATION OF TEST CASE PRIORITATION TECHNIQUES- HILL CLIMBING, REACTIVE GRASP AND TABUSEARCH

Why testing and analysis. Software Testing. A framework for software testing. Outline. Software Qualities. Dependability Properties

Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn. 4. Testing

Agenda. Predicate Testing. CSE 5321/4321, Ali Sharifara, UTA

Keywords Test case prioritization, TCP, software testing, Basic path testing, Source code analysis

Advanced Software Testing Understanding Code Coverage

Testing Theory. Agenda - What will you learn today? A Software Life-cycle Model Which part will we talk about today? Theory Lecture Plan

Introduction to Software Testing Chapter 3, Sec# 1 & 2 Logic Coverage

The testing process. Component testing. System testing

AUTOMATIC TEST DATA GENERATION USING DATA FLOW INFORMATION

Génie Logiciel Avancé

CS 4387/5387 SOFTWARE V&V LECTURE 4 BLACK-BOX TESTING

The Bizarre Truth! Automating the Automation. Complicated & Confusing taxonomy of Model Based Testing approach A CONFORMIQ WHITEPAPER

Testing: Test design and testing process

An Evaluation of the Effectiveness of Symbolic Testing

Testing & Symbolic Execution

MTAT : Software Testing

Formal Approach in Software Testing

Smart Test Case Quantifier Using MC/DC Coverage Criterion

SE 3S03. Zahra Ali. Week of Feb 22, 2016

Model Based Testing Using UML Diagram

Analytic Performance Models for Bounded Queueing Systems

MACHINE LEARNING BASED METHODOLOGY FOR TESTING OBJECT ORIENTED APPLICATIONS

SOFTWARE TESTING UNIT II TEST CASE DESIGN

Dataflow-based Coverage Criteria

4 Algorithms. Definition of an Algorithm

MTAT : Software Testing

Finite State Verification. CSCE Lecture 21-03/28/2017

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

SE 3S03 - Tutorial 10. Helen Brown. Week of Mar 23, 2015

Verification and Validation. Assuring that a software system meets a user s needs. Verification vs Validation. The V & V Process

Chapter 9. Software Testing

Part 5. Verification and Validation

Motivation State Machines

Specification-based Testing 2

In this Lecture you will Learn: Testing in Software Development Process. What is Software Testing. Static Testing vs.

Transcription:

MSc Software Testing and Maintenance MSc Prófun og viðhald hugbúnaðar Fyrirlestrar 31 & 32 Structural Testing White-box tests. 27/1/25 Dr Andy Brooks 1

Case Study Dæmisaga Reference Structural Testing of Programs, A Survey, A A Omar and F A Mohammed, ACM SIGSOFT Software Engineering Notes vol 14 no 2, April 1989, pp 62-7. plus extra teacher s notes 27/1/25 Dr Andy Brooks 2

Structural testing method The static analyis phase involves deriving the program flowgraph as a collection of vertices and edges. Each vertex represents a statement. Each edge between two vertices represents the control flow. The path selection phase involves choosing a finite set of paths in the flowgraph with a view to satisfying one or more coverage criteria. 27/1/25 Dr Andy Brooks 3

Structural testing method The test case generation phase involves generating the input data necessary to test the selected paths. The dynamic analysis phase involves executing the program using the test data and analysing the output produced. compare expected output with actual output 27/1/25 Dr Andy Brooks 4

Static Analysis The program is assumed to have compiled successfully. Each executable statement is assigned a number. Each statement is represented as a node with its number inside. An arc represents the transition from one statement to another. A sequence of nodes with only one incoming and one outgoing arc can be reduced to a single node. 27/1/25 Dr Andy Brooks 5

Figure 1 Sample Fortran program 1 READ(1,3) I, J, K 3 FORMAT(3I4) 2 IF (I.EQ.) GO TO 3 3 A = SQRT(I**2 + J**2) 4 B = I+J 5 GO TO 4 6 3 A = SQRT(J**2 + K**2) 7 B = J+K 8 4 WRITE(2,4) A, B 4 FORMAT(2F8.3) 9 STOP 27/1/25 Dr Andy Brooks 6

27/1/25 Dr Andy Brooks 7 1 2 3 4 5 8 9 6 7 1 2 3 8 9 6 9 1 8 1 6 1 3 1 1 2 1 1 9 8 6 3 2 1 program graph reduced program graph matrix representation of the reduced graph

extra Drawing program graphs Sequence If While Switch Non-branching sequence of statements 27/1/25 Dr Andy Brooks 8

extra Cyclomatic Complexity (CC) The cyclomatic complexity of a program graph may be calculated in 3 ways. 1. Number of regions no. bounded areas + the unbounded area surrounding graph 2. Number of edges - number of nodes + 2 3. Number of predicate nodes + 1 switch is not a predicate node 27/1/25 Dr Andy Brooks 9

extra Cyclomatic Complexity (CC) The value of cyclomatic complexity defines the number of independent paths and provides an upper bound for the number of tests that must be conducted to ensure all statements have been executed at least once. An independent path must traverse at least one edge that has not been traversed before. Basis path testing involves writing test cases to execute all the independent paths. 27/1/25 Dr Andy Brooks 1

extra Cyclomatic Complexity is 5. At least 5 test cases are needed to ensure statement coverage and that every predicate has been evaluated true and false at least once. Code with high complexity (high CC) may get targeted for additional tests. But note that there are disagreements over the theoretical foundation and usefulness of the CC metric. MAXV is the maximum cyclomatic complexity value for any single method within a class. 27/1/25 Dr Andy Brooks 11

path selection criteria/control flow criteria 3.1.1 execute each statement at least once This criteria is poor and various classes of errors are undetected. If X=X+Y is erroneously written X=X-Y and the test case sets Y to, no error will be detected. If X=X*2 is erroneously written X=X+2 and the test case sets X to 2, no error will be detected. 27/1/25 Dr Andy Brooks 12

path selection criteria/control flow criteria 3.1.1 execute each statement at least once F P erroneous transfer of control T S1 S2 If the test data causes P to be true then correct results are output. But the erroneous transfer of control when P is false will be undetected. 27/1/25 Dr Andy Brooks 13

path selection criteria/control flow criteria 3.1.2 exhaustive path testing In exhaustive path testing, each path in the program is executed at least once. However, even for small programs, the number of paths can be extremely large. Exhaustive testing is an impossible task. Even if exhaustive testing were possible, a program can still contain errors: There is no guarantee the program meets its specification. A program may be incorrect because of missing paths. If A-B is written instead of ABS(A-B), this error may not be detected by a test. 27/1/25 Dr Andy Brooks 14

path selection criteria/control flow criteria 3.1.2 exhaustive path testing 2 iterations A The number of unique logical paths between A and B is: 5 2 + 5 19 +... + 5 1 K 1 14 Executing a path every 5 minutes would take around one billion years. Executing a path every second would take around three million years. B 27/1/25 Dr Andy Brooks 15

path selection criteria/control flow criteria 3.1.3 decision coverage (branch testing) Each branch is executed at least once. This means each decision has a true and false outcome at least once. This means each statement is executed at least once. For multi-way decisions (case, switch), the test cases exercise all possible outcomes. 27/1/25 Dr Andy Brooks 16

path selection criteria/control flow criteria 3.1.4 essential branches criteria In normal branch testing, all branches are treated equally. This means that there are many branches which are executed by many test data. In essential branch testing, redundant test cases are removed by considering only essential branches. essential essential 27/1/25 Dr Andy Brooks 17

path selection criteria/control flow criteria 3.1.5 condition coverage criterion But condition coverage may not satisfy branch coverage. Assume IF (A and B) is being tested. One test case could be: A is true, B is false Another test case could be: A is false, B is true But these two test cases do not cause the THEN clause of the IF to be executed. 27/1/25 Dr Andy Brooks 18

path selection criteria/control flow criteria 3.1.6 decision/condition coverage criterion Each condition in a decision takes on all possible outcomes at least once. Each decision has a true and false outcome at least once. But: if an OR is found to be true early, subsequent conditions need not be evaluated. if an AND is found to be false early, subsequent conditions need not be evaluated. errors in logical expressions are not necessarily made visible. 27/1/25 Dr Andy Brooks 19

path selection criteria/control flow criteria 3.1.7 multiple-condition coverage criterion Test cases are written to cover all possible combinations of condition outcomes. Multiple-condition coverage also satisfies decision coverage, condition coverage, and decision/condition coverage. DO I = 1 TO M WHILE N... END 1. I < M and N is true 2. I < M and N is false 3. I > M and N is true 4. I > M and N is false If (A<1) & (B > 2) Draw a truth table for & and create test data for each outcome. A B Outcome 1 1 T 1 F 1 F F extra 27/1/25 2

extra Just another condition testing strategy If Grade == A test with: Grade < A Grade == A Grade > A 27/1/25 Dr Andy Brooks 21

extra Loop testing strategy Skipping the loop Go round once Go round twice Go round m times where m < n, the maximum number of iterations n-1, n, n+1 27/1/25 Dr Andy Brooks 22

Infeasible paths Testing can be problematic if infeasible paths are present. In traditional approaches, paths were chosen without regard to whether or not they were feasible. if (age < 21) System.out.println ("Youth is wonderful. Enjoy."); else if (age < 21) System.out.println ("No test will ever get here."); 27/1/25 Dr Andy Brooks 23

path selection criteria/data flow criteria 3.2. Data flow criteria During program execution a statement may: define a variable (assign a value) reference a variable (access a value) undefine a variable (variable destroyed) loop control variables are undefined once the loop terminates Four types of error are possible: A variable is undefined and then referenced. A variable is defined and then undefined. A variable is defined and then defined again. A variable is defined yet never referenced. A compiler might detect some of these. Which? By following the path of a variable, these four types of error can be detected. 27/1/25 Dr Andy Brooks 24

path selection criteria/data flow criteria 3.2. Data flow criteria 1. For each variable, select a path which contains a definition use of the variable, then either a computational or predicate use of that variable. 2. For each variable, select all the paths which include both a definition of the variable and a predicate use of the variable. 3. For each variable, select all the paths which include both a definition of the variable and a computation use of the variable. 4. For each variable, select all the paths which define the variable, then make computation and predicate use of it. This family of test criteria fall between branch testing and every path testing in terms of difficulty of fulfillment. 27/1/25 Dr Andy Brooks 25

4. Test case generation Work out the test inputs required for each selected test path. Performing this task manually can take a lot of time. Alternatively, generate test data randomly and obtain feedback on which paths have been executed by instrumenting the software under test. Continue to generate test data at random until all the selected test paths have been executed at least once. Information about the number of times a test path has been executed can be useful. 27/1/25 Dr Andy Brooks 26

7. Reliability and testing strategies adequacy A set T of test data for a program P is reliable if it reveals that P contains an error whenever P is incorrect. But we cannot construct such reliable test data. Empirically, Howden (1976) found that path testing was almost reliable for about 65% of program errors across 11 programs. But the programs involved were very simple in which each path could be tested. And not all error types were considered. 27/1/25 Dr Andy Brooks 27

8. Conclusion Structural testing comprises four phases: static analysis phase flowgraph developed path selection phase control flow criteria data flow criteria test case generation phase possibly using random test data and instrumented software under test dynamic analysis phase compare expected and actual output 27/1/25 Dr Andy Brooks 28

8. Conclusion But although we can find a systematic and automated method of testing, yet the testing theory has failed to yield any meaningful comparisons of methods. 27/1/25 Dr Andy Brooks 29

8. Conclusion What we shall try to do is to try different combination of methods to extract empirically the optimal combination. 27/1/25 Dr Andy Brooks 3