Test case design techniques I: Whitebox testing CISS



Similar documents
Test case design techniques I: Whitebox testing CISS

Test Case Design Techniques

Introduction to Computers and Programming. Testing

Test case design techniques II: Blackbox testing CISS

Different Approaches to White Box Testing Technique for Finding Errors

Software Testing. Jeffrey Carver University of Alabama. April 7, 2016

Tool-Assisted Unit-Test Generation and Selection Based on Operational Abstractions

APPROACHES TO SOFTWARE TESTING PROGRAM VERIFICATION AND VALIDATION

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Selecting Software Testing Criterion based on Complexity Measurement

Dataflow approach to testing Java programs supported with DFC

Standard for Software Component Testing

Software Engineering Introduction & Background. Complaints. General Problems. Department of Computer Science Kent State University

A Formal Model of Program Dependences and Its Implications for Software Testing, Debugging, and Maintenance

Introduction to Software Testing Chapter 8.1 Building Testing Tools Instrumentation. Chapter 8 Outline

Logistics. Software Testing. Logistics. Logistics. Plan for this week. Before we begin. Project. Final exam. Questions?

Automatic Test Data Synthesis using UML Sequence Diagrams

Software Testing. Quality & Testing. Software Testing

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

CSTE Mock Test - Part III Questions Along with Answers

1 White-Box Testing by Stubs and Drivers

each college c i C has a capacity q i - the maximum number of students it will admit

2 SYSTEM DESCRIPTION TECHNIQUES

Optimizations. Optimization Safety. Optimization Safety. Control Flow Graphs. Code transformations to improve program

Software Testing Strategies and Techniques

Software testing. Objectives

QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall

Search-based Data-flow Test Generation

Graph Theory Problems and Solutions

Experimental Comparison of Concolic and Random Testing for Java Card Applets

Comparing the effectiveness of automated test generation tools EVOSUITE and Tpalus

Formal Software Testing. Terri Grenda, CSTE IV&V Testing Solutions, LLC

Introduction to Automated Testing

Software Testing. System, Acceptance and Regression Testing

Small Maximal Independent Sets and Faster Exact Graph Coloring

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland

Contents. Introduction and System Engineering 1. Introduction 2. Software Process and Methodology 16. System Engineering 53

EVALUATING METRICS AT CLASS AND METHOD LEVEL FOR JAVA PROGRAMS USING KNOWLEDGE BASED SYSTEMS

Software Project Models

Genetic Algorithm Based Test Data Generator

Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

National University of Ireland, Maynooth MAYNOOTH, CO. KILDARE, IRELAND. Testing Guidelines for Student Projects

Sample Exam Syllabus

Test Coverage Criteria for Autonomous Mobile Systems based on Coloured Petri Nets

Coverage Criteria for Search Based Automatic Unit Testing of Java Programs

Computer Science 217

Specification and Analysis of Contracts Lecture 1 Introduction

Measurement Information Model

Software Testing. 1 Introduction. Gregory M. Kapfhammer Department of Computer Science Allegheny College gkapfham@allegheny.edu

VIRTUAL LABORATORY: MULTI-STYLE CODE EDITOR

A New Software Data-Flow Testing Approach via Ant Colony Algorithms

Flowcharting, pseudocoding, and process design

Simulation and Lean Six Sigma

Going Faster: Testing The Web Application. By Adithya N. Analysis and Testing of Web Applications Filippo Ricca and Paolo Tonella

Improved Software Testing Using McCabe IQ Coverage Analysis

AUTOMATED SOFTWARE TEST DATA GENERATION: DIRECTION OF RESEARCH

Random vs. Structure-Based Testing of Answer-Set Programs: An Experimental Comparison

6. Control Structures

Testing Introduction. IEEE Definitions

Dynamic programming formulation

Scheduling Shop Scheduling. Tim Nieberg

ALGORITHMS AND FLOWCHARTS

SYSM 6304: Risk and Decision Analysis Lecture 5: Methods of Risk Analysis

How To Understand Software Engineering

2) Write in detail the issues in the design of code generator.

Transparent Monitoring of a Process Self in a Virtual Environment

Lecture Notes on Linear Search

New Tools for Testing Web Applications with Python

1.3 Conditionals and Loops

Reducing Clocks in Timed Automata while Preserving Bisimulation

Regression Verification: Status Report

(Refer Slide Time: 01:52)

CHAPTER_3 SOFTWARE ENGINEERING (PROCESS MODELS)

Unit Title: Personnel Information Systems Unit Reference Number: F/601/7510 Guided Learning Hours: 160 Level: Level 5 Number of Credits: 18

Fault Localization in a Software Project using Back- Tracking Principles of Matrix Dependency

Two-way selection. Branching and Looping

Good FORTRAN Programs

Software Engineering. Software Testing. Based on Software Engineering, 7 th Edition by Ian Sommerville

Calculator. Introduction. Requirements. Design. The calculator control system. F. Wagner August 2009

Measuring Software Complexity to Target Risky Modules in Autonomous Vehicle Systems

Fail early, fail often, succeed sooner!

Regression Testing Based on Comparing Fault Detection by multi criteria before prioritization and after prioritization

Code Obfuscation. Mayur Kamat Nishant Kumar

Clustering and scheduling maintenance tasks over time

EECS 583 Class 11 Instruction Scheduling Software Pipelining Intro

5 INTEGER LINEAR PROGRAMMING (ILP) E. Amaldi Fondamenti di R.O. Politecnico di Milano 1

Transcription:

Test case design techniques I: Whitebox testing

Overview What is a test case Sources for test case derivation Test case execution White box testing Flowgraphs Test criteria/coverage Statement / branch / decision / condition / path coverage Looptesting Data flow testing Def-use pairs Efficiency of different criteria

Types of Testing

V - Model requirements acceptance test spec acceptance test specification system test spec system test architecture spec integration test spec integration test detailed design module test spec module test implementation code unit test spec unit-test

What is a Test? Test Cases Test Data Output Software under Test Oracle Correct result?

Development of Test Cases Complete testing is impossible Testing cant guarantee the absence of faults How to select subset of test cases from all possible test cases with a high chance of detecting most faults? Test Case Design Strategies

Sources for test case design The requirements to the program (its specification) An informal description A set of scenarios (use cases) A set of sequence diagrams A state machine The program itself A set of selection criteria Heuristics Experience

Test case execution Single stepping via a debugger Very clumsy for large programs Hard to rerun Manual via a set of function calls Hard to check when the number of test cases grows Fully automatic without programmers assistance Not possible so far Offline/online Fully automatic with programmers assistance Started with Junit State of the art Growing interest

White-Box Testing Testing based on program code Extent to which (source) code is executed, i.e. Covered Different kinds of coverage : statement coverage path coverage (multiple-) condition coverage decision / branch coverage loop coverage definition-use coverage..

White box testing: flow graphs Syntactic abstraction of source code Ressembles classical flow charts Forms the basis for white box test case generation principles Purpose of white box test case generation: Coverage of the flow graph in accordance with one or more test criteria

Flow graph construction sequence while if until case

White-Box : Statement Testing Execute every statement of a program Relatively weak criterion Weakest white-box criterion

Example : Statement Testing (result = 0+1+ + value, if this <= maxint, error otherwise) 1 PROGRAM maxsum ( maxint, value : INT ) 2 INT result := 0 ; i := 0 ; 3 IF value < 0 4 THEN value := - value ; 5 WHILE ( i < value ) AND ( result <= maxint ) 6 DO i := i + 1 ; 7 result := result + i ; 8 OD; 9 IF result <= maxint 10 THEN OUTPUT ( result ) 11 ELSE OUTPUT ( too large ) 12 END.

1 1 PROGRAM maxsum ( maxint, value : INT ) 2 INT result := 0 ; i := 0 ; 3 IF value < 0 4 THEN value := - value ; 5 WHILE ( i < value ) AND ( result <= maxint ) 6 DO i := i + 1 ; 7 result := result + i ; 8 OD; 9 IF result <= maxint 10 THEN OUTPUT ( result ) 11 ELSE OUTPUT ( too large ) 12 END. 2 3 4 5 6-7 9 11 10 12

Flow graph: Cyclomatic complexity #edges - #des + 2 Defines the maximal number of test cases needed to provide statement coverage Mostly applicable for Unit testing Strategy for statement coverage: 1. Derive flow graph 2. Find cyclomatic complexity #c 3. Determine at most #c independent paths through the program (add one new edge for each test case) 4. Prepare test cases covering the edges for each path (possibly fewer than #c cases)

Cyclomatic complexity? 1 1 PROGRAM maxsum ( maxint, value : INT ) 2 INT result := 0 ; i := 0 ; 3 IF value < 0 4 THEN value := - value ; 5 WHILE ( i < value ) AND ( result <= maxint ) 6 DO i := i + 1 ; 7 result := result + i ; 8 OD; 9 IF result <= maxint 10 THEN OUTPUT ( result ) 11 ELSE OUTPUT ( too large ) 12 END. 2 3 4 5 6-7 9 11 10 12

Example : Statement Testing start value < 0 value:= -value; (i<value) and (result<=maxint) result<=maxint i:=i+1; result:=result+i; Tests for complete statement coverage: maxint value 10-1 0-1 output(result); output( too large ); exit

White-Box : Path Testing Execute every possible path of a program, i.e., every possible sequence of statements Strongest white-box criterion Usually impossible: infinitely many paths ( in case of loops ) So: t a realistic option But te : ermous reduction w.r.t. all possible test cases ( each sequence of statements executed for only one value )

Example : Path Testing start output(result); value < 0 (i<value) and (result<=maxint) result<=maxint output( too large ); value:= -value; i:=i+1; result:=result+i; Path: start i:=i+1; result:=result+i; i:=i+1; result:=result+i;... i:=i+1; result:=result+i; output(result); exit exit

White-Box : Branch Testing Branch testing == decision testing Execute every branch of a program : each possible outcome of each decision occurs at least once Example: IF b THEN s1 ELSE s2 IF b THEN s1; s2 CASE x OF 1 :. 2 :. 3 :.

Example : Branch Testing start value < 0 (i<value) and (result<=maxint) value:= -value; i:=i+1; result:=result+i; Tests for complete statement coverage: maxint value 10-1 0-1 is t sufficient for branch coverage; result<=maxint output(result); output( too large ); exit Take: maxint value 10 3 0-1 for complete branch coverage

Example : Branch Testing start value < 0 (i<value) and (result<=maxint) value:= -value; i:=i+1; result:=result+i; maxint value -1-1 -1-1 -1-1 10 10 3 But: No green path! result<=maxint Needed : Combination of decisions output(result); output( too large ); 10-3 exit

Example : Branch Testing start value < 0 value:= -value; i:=i+1; result:=result+i; Sometimes there are infeasible paths ( infeasible combinations of conditions ) (i<value) and (result<=maxint) result<=maxint output(result); output( too large ); exit

White-Box : Condition Testing Design test cases such that each possible outcome of each condition in each decision occurs at least once Example: decision ( i < value ) AND (result <= maxint ) consists of two conditions : ( i < value ) AND (result <= maxint ) test cases should be designed such that each gets value true and false at least once

Example : Condition Testing start output(result); value < 0 (i<value) and (result<=maxint) result<=maxint exit output( too large ); value:= -value; i:=i+1; result:=result+i; ( i = result = 0 ) : maxint value i<value result<=maxint -1 1 true false 1 0 false true gives condition coverage for all conditions But it does t preserve decision coverage always take care that condition coverage preserves decision coverage : decision / condition coverage

White-Box : Multiple Condition Testing Design test cases for each combination of conditions Example: ( i < value ) (result <= maxint ) false false false true true false true true Implies decision-, condition-, decision/condition coverage But : exponential blow-up Again : some combinations may be infeasible

White-box: loop testing Statement and branch coverage are t sufficient Single loop strategy: Zero iterations One iteration Two iterations Typical number of iterations n-1, n, and n+1 iterations (n maximum number of allowable iterations) Nested loop strategy: Single loop strategy often intractable Select minimum values for outer loop(s) Treat inner loop as a single loop Work outwards and choose typical values for inner loops Concatenated loops: Treat as single, if independent Treat as nested, if dependent

Example : Loop testing value < 0 (i<value) and (result<=maxint) start value:= -value; i:=i+1; result:=result+i; Tests for complete loop coverage: maxint 15 0 15 1 15 2 15 3 6 4 15 5 value result<=maxint output(result); output( too large ); exit

White-box testing: Data Flow criteria Basic idea: For each variable definition (assignment), find a path (and a corresponding test case), to its use(s). A pair (definition,use) is often called a DU pair. Three dominant strategies: All-defs (AD) strategy: follow at least one path from each definition to some use of it All-uses (AU) strategy: follow at least one path for each DU pair All-du-uses strategy (ADUP): follow all paths between a DU pair Complements the testing power of decision coverage

Example: All-uses coverage 1 D m,v 1 PROGRAM maxsum ( maxint, value : INT ) 2 INT result := 0 ; i := 0 ; 3 IF value < 0 4 THEN value := - value ; 5 WHILE ( i < value ) AND ( result <= maxint ) 6 DO i := i + 1 ; 7 result := result + i ; 8 OD; 9 IF result <= maxint 10 THEN OUTPUT ( result ) 11 ELSE OUTPUT ( too large ) 12 END. U i,v,r,m 2 D r,i U v U v ;D v 3 4 U r,i ;D r,i 5 6-7 U r,m 9 Def-use pairs: Tests for complete all-uses coverage: 1-3,1-5,1-9,1-4 maxint value 2-5,2-9,2-6 4-5 0 0 0-1 U r 11 10 6-5,6-9,6-11 10 1 6-5-6 10 2 12

White-Box : Overview statement coverage condition coverage decision (branch) coverage decision/ condition coverage multiplecondition coverage path coverage

White-Box : Overview statement coverage all defs coverage decision (branch) coverage all uses coverage all du paths coverage path coverage

Additional techniques: mutation and random testing Mutation testing: Intended for evaluating the test cases Create at set of slightly modified mutants of the original program containing errors Run the test cases against the mutants Criteria All mutants must fail (strong) All mutants will eventually fail (weak) Random testing: Basic idea: run the program with arbitrary inputs Inherent problems: How to define the oracle for arbitrary inputs and how to decide to stop? Advantage: The program structure can be igred

Efficiency of white-box techniques: two studies Strategy #test cases %bugs found Random 35 93.7 Branch 3.8 91.6 All-uses 11.3 96.3 Random 100 79.5 Branch 34 85.5 All-uses 84 90.0