Advanced Software Engineering: Software Testing COMP 3702 Instructor: Anneliese Andrews.

Slides:



Advertisements
Similar presentations
Chapter 14 Software Testing Techniques - Testing fundamentals - White-box testing - Black-box testing - Object-oriented testing methods (Source: Pressman,
Advertisements

Chapter 14 Testing Tactics
DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Creator: ACSession No: 13 Slide No: 1Reviewer: SS CSE300Advanced Software EngineeringFebruary 2006 Testing - Techniques CSE300 Advanced Software Engineering.
Chapter 17 Software Testing Techniques
TESTING LOOPS ● Simple Loops ● Nested Loops ● Concatenated Loops ● Unstructured Loops.
1 “White box” or “glass box” tests “White Box” (or “Glass Box”) Tests.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Software Testing and Quality Assurance White Box Testing.
Testing an individual module
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Unit Testing CS 414 – Software Engineering I Don Bagert Rose-Hulman Institute of Technology January 16, 2003.
Software Engineering Lecture 12 Software Testing Techniques 1.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
1CMSC 345, Version 4/04 Verification and Validation Reference: Software Engineering, Ian Sommerville, 6th edition, Chapter 19.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Software Systems Verification and Validation Laboratory Assignment 3
System/Software Testing
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
CMSC 345 Fall 2000 Unit Testing. The testing process.
Path Testing + Coverage Chapter 9 Assigned reading from Binder.
Lecture 11 Testing and Debugging SFDV Principles of Information Systems.
Software Testing The process of operating a system or component under specified conditions, observing and recording the results, and making an evaluation.
Agenda Introduction Overview of White-box testing Basis path testing
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
White-box Testing.
Software Testing and Reliability Southern Methodist University CSE 7314.
Presented by: Ritesh Jain Date: 16-Jun-05 Software Quality Testing.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
Chapter 12: Software Inspection Omar Meqdadi SE 3860 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Web: assisted with templates and printinghttp:// Advanced Software Engineering: Software Testing COMP 3705(L3)
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
Software Testing Part II March, Fault-based Testing Methodology (white-box) 2 Mutation Testing.
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
Theory and Practice of Software Testing
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Dynamic Testing.
White Box Testing by : Andika Bayu H.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
Software Testing. SE, Testing, Hans van Vliet, © Nasty question  Suppose you are being asked to lead the team to test the software that controls.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.
Testing Integral part of the software development process.
CX Introduction to Web Programming Testing.
Chapter 17 Software Testing Techniques
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Software Testing.
Software Testing.
Software Engineering (CSI 321)
Loop Testing.
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
Software Testing (Lecture 11-a)
Chapter 14 Software Testing Techniques
“White box” or “glass box” tests
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Control Structure Testing
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Advanced Software Engineering: Software Testing COMP 3702 Instructor: Anneliese Andrews

Advanced Software Engineering: Software Testing News & Project  News  Project  Deadline 12/2: Outline of report  Book time

Advanced Software Engineering: Software Testing Lecture  Chapter 10 (Lab 3)  Software inspections  Fault content estimation  Chapter 5 (Lab 4)  White-box testing techniques

Advanced Software Engineering: Software Testing Inspections Individual inspection Meeting

Advanced Software Engineering: Software Testing Why inspect?  Main objective  Detect faults  Other objectives  Inform  Educate  Learn from (others) mistakes  Faults affect software quality negatively

Advanced Software Engineering: Software Testing What to inspect? Implementation Analysis & Requirements Design Integration & Function test System Test Inspection

Advanced Software Engineering: Software Testing Relative cost of faults Maintenance Source: Davis, A.M., “Software Requirements: analysis and specification”, 1990

Advanced Software Engineering: Software Testing How did it start?  Fagan inspections (IBM, early 1970’s, Checklist)  Phases  Overview, Preparation, Meeting, Rework, Follow- up Fault searching at meeting! – Synergy  Roles  Author (designer), reader (coder), tester, moderator  Classification  Major and minor

Advanced Software Engineering: Software Testing How did it start?  Fagan 1976  Inspections detected 82% of the faults  Unit testing detected 18% of the faults  Productivity was increased by 23%

Advanced Software Engineering: Software Testing Getting the best from inspections  The author  How do you react?  ”… is in the hot seat”  The development team  Better prepared  Feedback  Communication

Advanced Software Engineering: Software Testing Getting the best from inspections  The inspection team  Critical thinking  Ability to detect omissions  Who should participate in inspections?  Cost-effective verification  Minimising cost of correction  Is it cost-effective?

Advanced Software Engineering: Software Testing Inspections  Objective:  Detect faults  Collect data  Communicate information  Roles  Moderator  Reviewers (Inspectors)  Presenter  Author  Elements  Planned, structural meeting  Preparation important  Team – 3-6 people  Disadvantages  Short-term cost

Advanced Software Engineering: Software Testing Walkthroughs  Objective  Detect faults  Become familiar with the product  Roles  Presenter (author)  Reviewers (Inspectors)  Elements  Planned meeting  Team – 2-7 people  Brainstorm  Disadvantage  Find fewer faults

Advanced Software Engineering: Software Testing Cognitive View  Process  Comprehension – overview or preparation  Fault searching – preparation or meeting  Inexperienced reviewers  Concrete representation (syntax)  Experienced reviewers  Abstract representation (semantic)  Load less detailed information

Advanced Software Engineering: Software Testing Reading Techniques  Ad hoc  Checklist  Active Design Review  Defect-based reading  Perspective-based reading  Usage-based reading

Advanced Software Engineering: Software Testing Active design review  Active design review (1990)  Forces reviewers to actively inspect  Question-based e.g. how can this be implemented

Advanced Software Engineering: Software Testing Defect-based Reading

Advanced Software Engineering: Software Testing Perspective-based Reading  Scenarios  Purpose  Decrease overlap  Improved effectiveness Designer Tester User

Advanced Software Engineering: Software Testing Usage-Based Reading Modell av användningen Design

Advanced Software Engineering: Software Testing Inspection Techniques  N-fold inspections (1993)  N independent groups inspect the document  Small groups  Phased inspections (1985)  Two or several inspection sessions  With or without fault correction in-between

Advanced Software Engineering: Software Testing Inspection Techniques  Stepwise abstraction (1982)  Code  Decompose the code to subprograms  Each subprogram perform one function  Usability inspections  Focus on end user e.g. learnability, availability, understandability  Several sub-techniques e.g. Cognitive walk-through

Advanced Software Engineering: Software Testing Inspections Estimation Individual inspection Meeting

Advanced Software Engineering: Software Testing Capture-recapture

Advanced Software Engineering: Software Testing Capture-recapture

Advanced Software Engineering: Software Testing Presenting the Information Diagram with N, D, N-D, Reviewer data Reviewer 1 Overlap Diagram ^ ^^ ^ Reviewer 2 Reviewer 3

Advanced Software Engineering: Software Testing Capture-Recapture Models  Degree of freedom  Models  Estimators  Four basic models used for inspections  Prerequisites for all models  All reviewers work independently of each other  It is not allowed to inject or remove faults during inspection

Advanced Software Engineering: Software Testing Prerequisites Detection probabilities Fault number Detection probabilities Fault number Detection probabilities Fault number Detection probabilities Fault number

Advanced Software Engineering: Software Testing Testing Approaches requirements input events output Black Box Testing White Box Testing

Advanced Software Engineering: Software Testing There are many possible paths! loop < 20x If-then-else Selective Testing Exhaustive testing

Advanced Software Engineering: Software Testing a selected path Control flow testing Control flow testing Data flow testing Data flow testing Loop testing Loop testing Fault-based testing Fault-based testingSelective: Selective testing

Advanced Software Engineering: Software Testing Control flow – coverage Statement coverage Decision coverage Condition coverage Decision/ condition coverage Multiple condition coverage 1Each statement is executed at least once YYYYY 2Each decision takes on all possible outcomes at least once YYY 3Each condition in a decision takes on all possible outcomes at least once YYY 4All possible combinations of condition outcomes in each decision occur at least once Y

Advanced Software Engineering: Software Testing Statement coverage  Execute each statement at least once  Tools are used to monitor execution  Requirement may be:  no dead code

Advanced Software Engineering: Software Testing Decision/Branch coverage  McCabe cyclomatic The number of independent paths needed to cover all paths at least once in a program l Count number of conditional expressions. If compound conditional expressions, add one per compound item. l Visualize by drawing a flow graph l Alternative way: CC = #(edges) - #(nodes) +2

Advanced Software Engineering: Software Testing McCabe cyclomatic Control complexity vs Data complexity, an example: case A is when "One"=> :=1; when "Two"=> :=2; when "Three"=> :=3; when "Four"=> :=4; when "Five"=> :=5; end Case CC = 5 Strings : array (1..4) of STRING:= ("One","Two","Three","Four","Five"); i:=1; loop exit when Strings(i)=A; i:=i+1; end loop; CC = 2

Advanced Software Engineering: Software Testing  Test all possible conditions in a program  A condition in a program may contain:  Boolean operators and variables  Relational operators  Arithmetic expressions  …. Condition Coverage

Advanced Software Engineering: Software Testing Decision / Condition coverage Decision 1. A = 2; B = 300 (True) 2. A = 12; B = 300 (False) Condition (Decision/Condition) 1. A = 2; B = 300 (True) 2. A = 12; B = 200 (False) Multiple condition 1. A = 2; B = 200 (False) 2. A = 12; B = 200 (False) 3. A = 2; B = 300 (True) 4. A=12; B=300 (True) If A 250 then …

Advanced Software Engineering: Software Testing Example (Decision coverage) void f() { if(count > 10){ fixed_count = fixed_count + count; done = 1; } else if(count >5){ fixed_count --; } else { fixed_count = count * 4; } void f() { if(count > 10){ fixed_count = fixed_count + count; done = 1; } else if(count >5){ fixed_count --; } else { fixed_count = count * 4; }

Advanced Software Engineering: Software Testing Flow Graph if(count > 10) void f() fixed_count = fixed_count + count; done = 1; if(count >5) fixed_count --; fixed_count = count * 4; return;

Advanced Software Engineering: Software Testing Decision Coverage  Independent paths: (a) 1, 2, 3, 8 (b) 1, 2, 4, 6, 7, 8 (c) 1, 2, 4, 5, 7, 8  Test cases: (a) count  13 (b) count  8 (c) count  2

Advanced Software Engineering: Software Testing Example program The liability procedure: procedure liability (age, sex, married, premium); begin premium := 500; if ((age < 25) and (sex = male) and (not married)) then premium := premium ; else begin if (married or (sex = female)) then premium := premium – 200; if ((age > 45) and (age < 65)) then premium := premium – 100; end;

Advanced Software Engineering: Software Testing Statement coverage There are only two statements in this program, and any combination of inputs will provide coverage for both statements. Different definitions!!! Statement coverageAgeSexMarriedTest case

Advanced Software Engineering: Software Testing Decision/Branch coverage Decision coverageAgeSexMarriedTest case IF-1< 25MaleFalse(1) 23 M F IF-1< 25FemaleFalse(2) 23 F F IF-2*Female*(2) IF-2>= 25MaleFalse(3) 50 M F IF-3<= 45Female*(2) IF-3> 45, < 65**(3)

Advanced Software Engineering: Software Testing Condition coverage Decision coverageAgeSexMarriedTest case IF-1< 25FemaleFalse(1) 23 F F IF-1>= 25MaleTrue(2) 30 M T IF-2*MaleTrue(2) IF-2*FemaleFalse(1) IF-3<= 45**(1) IF-3> 45**(3) 70 F F IF-3< 65**(2) IF-3>= 65**(3)

Advanced Software Engineering: Software Testing Data Flow Testing  Identifies paths in the program that go from the assignment of a value to a variable to the use of such variable, to make sure that the variable is properly used.  Definitions  Def – assigned or changed  Uses – utilized (not changed) Computation: e.g. right-hand side of an assignment, an index of an array, parameter of a function. Predicate: branching the execution flow, e.g. in an if statement, while statement, for statement.  Example: All def-use paths (DU) requires that each DU chain is covered at least once

Advanced Software Engineering: Software Testing Data Flow Testing – Example [1] void k() { [2] x = 11; [3] if (p(cond1)) { [4] y = x + 1; [5] } else if (q(cond2)) { [6] w = x + 3; [7] } else { [8] w = y + 1; [9] } [10]} [1] void k() { [2] x = 11; [3] if (p(cond1)) { [4] y = x + 1; [5] } else if (q(cond2)) { [6] w = x + 3; [7] } else { [8] w = y + 1; [9] } [10]} Considering x, there are two DU paths: (a) [2]-[4] (b) [2]-[6] We need therefore to derive test cases to match the following conditions: (a) k() is executed and p(cond1) is true (b) k() is executed and p(cond1) is false and q(cond2) is true

Advanced Software Engineering: Software Testing simple loop nested loops concatenated loops unstructured loops Loop testing

Advanced Software Engineering: Software Testing Loop testing: simple loops Minimum conditions - simple loops 1. skip the loop entirely 2. only one pass through the loop 3. two passes through the loop 4. m passes through the loop m < n 5. (n-1), n, and (n+1) passes through the loop where n is the maximum number of allowable passes

Advanced Software Engineering: Software Testing Nested loops  Extend simple loop testing  Reduce the number of tests:  start at the innermost loop; set all other loops to minimum values  conduct simple loop test; add out of range or excluded values typical  work outwards while keeping inner nested loops to typical values  continue until all loops have been tested

Advanced Software Engineering: Software Testing Concatenated loops  Same strategies as simple loops if the loops counters are independent  Same strategies as nested loops if the loops counters depend on each other: int k; k=0;k<10;k++ for (k=0;k<10;k++) { w(); if p(m) break; } ;k<10;k++ for (;k<10;k++) { r(); }

Advanced Software Engineering: Software Testing Mutation testing (fault-based testing) A method for evaluation of testing effectiveness 1. Mutate the program using the mutation operators 2. Run test suite on mutants 3. Obtain statistics on live and dead mutants 4. Create more test cases and iterate 2-4 until sufficient number of mutants are killed

Advanced Software Engineering: Software Testing Example mutation operators  Relational operator replacement  Logical operator replacement  Arithmetic operator replacement  Unary operator removal/insertion  Comparable constant replacement  Comparable variable replacement  Comparable array replacement

Advanced Software Engineering: Software Testing Example nbrs = new int[range] public int max(int[] a) { int imax := 0; for (int i = 1; i < range; i++) if a[i] > a[imax] imax:= i; return imax; } a[0]a[1]a[2] TC1123 TC2132 TC3312

Advanced Software Engineering: Software Testing Relational operator mutant nbrs = new int[range] public int max(int[] a) { int imax := 0; for (int i = 1; i < range; i++) if a[i] >= a[imax] imax:= i; return imax; } a[0]a[1]a[2] TC1123 TC2132 TC3312

Advanced Software Engineering: Software Testing Variable operator mutant nbrs = new int[range] public int max(int[] a) { int imax := 0; for (int i = 1; i < range; i++) if i > a[imax] imax:= i; return imax; } a[0]a[1]a[2] TC1123 TC2132 TC3312

Advanced Software Engineering: Software Testing Variable operator mutant nbrs = new int[range] public int max(int[] a) { int imax := 0; for (int i = 0; i < range; i++) if a[i] > a[imax] imax:= i; return imax; } a[0]a[1]a[2] TC1123 TC2132 TC3312

Advanced Software Engineering: Software Testing Why is white-box testing not enough?  Missing features  Missing code  Timing and concurrency issues  Different states of the software  Astronomical amount of different paths through the software  Different paths can reveal different defects  Variations of input conditions  Variations of data  Qualities  Performance  Robustness  Reliability  Usability  …

Advanced Software Engineering: Software Testing This week  Project  Find/read literature  Outline of report to your supervisor ( )  Next week: book time with supervisor (if needed)  Lab  Usage-based testing and reliability  Report of Lab 1 to Carina