Topics in Software Testing

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

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

Software Testing. Software Testing

Aerospace Software Engineering

Software Engineering

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

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

Part 5. Verification and Validation

Verification and Validation. Verification and validation

Chapter 10. Testing and Quality Assurance

MONIKA HEINER.

Bridge Course On Software Testing

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

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Testing Process and Methods. CS 490MT/5555, Spring 2017, Yongjie Zheng

The testing process. Component testing. System testing

Lecture 15 Software Testing

Chapter 11, Testing. Using UML, Patterns, and Java. Object-Oriented Software Engineering

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

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

Manuel Oriol, CHCRC-C, Software Testing ABB

10. Software Testing Fundamental Concepts

Lecture 10: Introduction to Correctness

INTRODUCTION TO SOFTWARE ENGINEERING

Quality Assurance in Software Development

Chapter 9. Software Testing

Testing & Debugging TB-1

Software Testing. Software Testing. in the textbook. Chapter 8. Verification and Validation. Verification and Validation: Goals

Lecture 20: SW Testing Presented by: Mohammad El-Ramly, PhD

Software Quality Assurance. David Janzen

Chapter 8 Software Testing. Chapter 8 Software testing

People tell me that testing is

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Software testing. Ian Sommerville 2006 Software Engineering, 8th edition. Chapter 23 Slide 1

Verification and Validation

Verification and Validation

Terminology. There are many different types of errors and different ways how we can deal with them.

Lecture 9. Verification and Validation. Assuring that a software system meets a user's needs. Tutorial Questions. Verification and Validation

Verification and Validation

No Source Code. EEC 521: Software Engineering. Specification-Based Testing. Advantages

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

SFWR ENG 3S03: Software Testing

Program Correctness and Efficiency. Chapter 2

Introduction to Dynamic Analysis

Computer Science and Software Engineering University of Wisconsin - Platteville 9-Software Testing, Verification and Validation

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, September 18, ISSN SOFTWARE TESTING

An Introduction to Systematic Software Testing. Robert France CSU

Software Engineering and Scientific Computing

Black Box Testing. EEC 521: Software Engineering. Specification-Based Testing. No Source Code. Software Testing

1 Visible deviation from the specification or expected behavior for end-user is called: a) an error b) a fault c) a failure d) a defect e) a mistake

EECS 4313 Software Engineering Testing. Topic 01: Limits and objectives of software testing Zhen Ming (Jack) Jiang

Software Engineering (CSC 4350/6350) Rao Casturi

Testing is the process of evaluating a system or its component(s) with the intent to find whether it satisfies the specified requirements or not.

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

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, April- ICITDA 18,

Verification and Validation

Programming Embedded Systems

Unit Testing as Hypothesis Testing

Darshan Institute of Engineering & Technology for Diploma Studies

Chap 2. Introduction to Software Testing

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 11/10/2015

Software Engineering Testing and Debugging Testing

Examination Questions Time allowed: 1 hour 15 minutes

Getting those Bugs Out --Software Testing

Software Engineering Fall 2014

18-642: Testing Overview

Sample Exam Syllabus

Object-Oriented and Classical Software Engineering

Object-Oriented and Classical Software Engineering

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus

Computational Systems COMP1209

UNIT-4 Black Box & White Box Testing

Verification and Validation

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

Software Testing. Minsoo Ryu. Hanyang University. Real-Time Computing and Communications Lab., Hanyang University

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 15 Testing

Objectives. Chapter 19. Verification vs. validation. Topics covered. Static and dynamic verification. The V&V process

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

Software Quality Assurance (SQA) Software Quality Assurance

XVIII. Software Testing. Laurea Triennale in Informatica Corso di Ingegneria del Software I A.A. 2006/2007 Andrea Polini

Race Catcher. Automatically Pinpoints Concurrency Defects in Multi-threaded JVM Applications with 0% False Positives.

Testing: Test design and testing process

Software Engineering

UNIT-4 Black Box & White Box Testing

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

Testing. CMSC 433 Programming Language Technologies and Paradigms Spring A Real Testing Example. Example (Black Box)?

Part I: Preliminaries 24

Sample Question Paper. Software Testing (ETIT 414)

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

CS 424 Software Quality Assurance & Testing LECTURE 3 BASIC CONCEPTS OF SOFTWARE TESTING - I

F. Tip and M. Weintraub FUNCTIONAL TESTING

Object-Oriented Design Lecture 5 CSU 370 Fall 2008 (Pucella) Friday, Sep 26, 2008

EXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist:

[IT6004-SOFTWARE TESTING] UNIT 2

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

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

The Importance of Test

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

Basic Definitions: Testing

Higher-order Testing. Stuart Anderson. Stuart Anderson Higher-order Testing c 2011

Transcription:

Dependable Software Systems Topics in Software Testing Material drawn from [Beizer, Sommerville]

Software Testing Software testing is a critical element of software quality assurance and represents the ultimate review of: specification design coding Software life-cycle models (e.g., waterfall) frequently include software testing as a separate phase that follows implementation!

Software Testing (Cont d) Contrary to life-cycle models, testing is an activity that must be carried out throughout the life-cycle. It is not enough to test the end product of each phase. Ideally, testing occurs during each phase.

Software Testing Terminology Error: A measure of the difference between the actual and the ideal. Fault: A condition that causes a system to fail in performing its required function. Failure: The inability of a system or component to perform a required function according to its specifications. Debugging: The activity by which faults are identified and rectified.

Software Testing Myths If we were really good at programming, there would be no bugs to catch. There are bugs because we are bad at what we do. Testing implies an admission of failure. Tedium of testing is a punishment for our mistakes.

Software Testing Myths (Cont d) All we need to do is: concentrate use structured programming use OO methods use a good programming language...

Software Testing Reality Human beings make mistakes, especially when asked to create complex artifacts such as software systems. Studies show that even good programs have 1-3 bugs per 100 lines of code. People who claim that they write bug-free software probably haven t programmed much.

Goals of Testing Discover and prevent bugs. The act of designing tests is one of the best bug preventers known. (Test, then code philosophy) The thinking that must be done to create a useful test can discover and eliminate bugs in all stages of software development. However, bugs will always slip by, as even our test designs will sometimes be buggy.

Phases in a Testers Mental Life Testing is debugging. The purpose of testing is to show that the software works. The purpose of testing is to show that the software doesn t work. The purpose of testing is to reduce the risk of failure to an acceptable level.

Testing Isn t Everything Other methods for improving software reliability are: Inspection methods: Walkthroughs, formal inspections, code reading. Design style: Criteria used by programmers to define what they mean by a good program. Static analysis: Compilers take over mundane tasks such as type checking. Good Programming Languages and Tools: Can help reduce certain kinds of bugs (e.g., Lint).

Testing Versus Debugging The purpose of testing is to show that a program has bugs. The purpose of debugging is to find the faults that led to the program s failure and to design and implement the program changes that correct the faults. Testing is a demonstration of failure or apparent correctness. Debugging is a deductive process.

Testing Versus Debugging (Cont d) Testing proves a programmer s failure. Debugging is a programmer s vindication. Testing can be automated to a large extent. Automatic debugging is still a dream. Much of testing can be done without design knowledge (by an outsider). Debugging is impossible without detailed design knowledge (by an insider).

Function Versus Structure Functional Testing: Program is treated as a black box. Program is subjected to inputs, and its outputs are verified for conformance to specified behavior. Implementation details do not matter. Takes a user s point of view. In principle, can detect all bugs in an infinite amount of time.

Function Versus Structure (Cont d) Structural Testing: Aims at exercising the different control and data structures used in the program. Criteria are precise as they are based on program structures (i.e., are quite precise). Looks at implementation details. Takes a developer s point of view. Is inherently finite but cannot detect all faults.

Designer Versus Tester The designer and the tester can be completely separated if only functional testing is performed. In structural testing the tester, like the designer, has intimate knowledge of the structure of the program.

Designer Versus Tester (Cont d) The more the tester knows about the design, the more likely he will eliminate useless tests (functional differences handled by the same code). Testers that have design knowledge may have the same misconceptions as the designer.

Designer Versus Tester (Cont d) Lack of design knowledge may help the tester to develop test cases that a designer would never have thought of. Lack of design knowledge may result in inefficient testing and blindness to missing functions and strange cases.

Small Versus Large Systems For small systems with one user, quality assurance may not be a major concern. As systems scale up in size and number of users, quality assurance becomes more of a concern. As systems dramatically scale up in size (e.g., millions of lines of code), our quality criteria may have to change as exhaustive testing may not be economically possible. E.g., a 75% code coverage may be acceptable.

Programs and their Environment A program s environment is the hardware and systems software required to make it run. Programmers should learn early in their careers that it is not smart to blame the environment for bugs. Bugs in the environment are rare because most bugs have been found over a long period of usage by a large number of users.

Myths About Bugs Benign Bug Hypothesis: Bugs are nice, tame, and logical. Bug Locality Hypothesis: A bug discovered within a component affects only that component s behavior. Control Bug Dominance: Most bugs are in the control structure of programs. Corrections Abide: A corrected bug remains correct.

Myths About Bugs (Cont d) Silver Bullets: A language, design method, environment grants immunity from bugs. Sadism Suffices: All bugs can be caught using low cunning and intuition. (Only easy bugs can be caught this way.)

Test Cases Test cases are formal procedures: inputs are prepared outcomes are predicted tests are documented commands are executed results are observed All of these steps are subject to mistakes. Tests may have bugs themselves.

Levels of Testing Unit Testing: A unit is the smallest testable piece of software (e.g., function). Component Testing: A component is an integrated aggregate of one or more units (e.g., module). Integration Testing: This testing is used to demonstrate that a combination of successfully tested components has bugs.

Levels of Testing (Cont d) System Testing: A system is a very large component. System testing includes testing for: performance security system recovery from failure

Testing Oracles A testing oracle is any program, process, or body of data that specifies the expected outcome of a set of tests. Oracles are often defined as a set of input/expected outcome pairs.

Sources of Testing Oracles Regression Test Suites: Test software using the test suites developed for previous versions of the same software. Purchased Test Suites: Highly standardized software (compilers, mathematical routines) often have commercially available test suites. Existing Program: A working, trusted, program that is being re-hosted to a new language or O/S.

Is Complete Testing Possible? NO. Complete testing is both practically and theoretically impossible for non-trivial software.

Complete Functional Testing A complete functional test would consist of subjecting a program to all possible input streams. Even if the program has an input stream of 10 characters, it would require tests. At 1 microsecond/test, exhaustive functional testing would require more time than twice the current estimated age of the universe! 80 2

Complete Structural Testing One should design enough tests to ensure that every path is executed at least once. What if the loops never terminate? Even if loops terminate, the number of paths may be too large.

How About Correctness Proofs? Requirements are specified in a formal language. Each program statement is used in a step of an inductive proof. In practice, such proofs are time consuming and expensive.

How About Correctness Proofs? (Cont d) Proving the consistency and completeness of a specification is a provably unsolvable problem, in general. Proofs may have bugs.

A Theory of Program Testing A program is a function: P : D! A program specification is the function: S : D! R R Input domain is D, output range is R. Proving program correctness is the process of demonstrating that: P ( d) = S( d)," d! D

A Theory of Program Testing (Cont d) A program P is correct with respect to the specification S if the program behavior matches the specified behavior for all possible inputs in D. This is impossible to achieve for any reasonably complex program.

A Theory of Program Testing (Cont d) Software Testing is the process of demonstrating program correctness by selecting a subset of set D called T such that: T is a finite subset of D. If S(t) is incorrect for some t in T, P(t) must be incorrect also. If S(t) is correct for some t in T, P(t) must be correct also.

A Theory of Program Testing (Cont d) A testing strategy is a set of rules that outline: the criteria by which T is selected (test selection criteria) the properties of the program that must be exercised (test coverage criteria)

Program Testing Can reveal the presence of faults NOT their absence. A successful test is a test which discovers one or more faults. Only validation technique for nonfunctional requirements. Should be used in conjunction with static verification.

Defect Testing The objective of defect testing is to discover defects in programs. A successful defect test is a test which causes a program to behave in an anomalous way. Tests show the presence not the absence of defects.

Testing Priorities Only exhaustive testing can show a program is free from defects. However, exhaustive testing is impossible. Tests should exercise a system s capabilities rather than its components. Testing old capabilities is more important than testing new capabilities. Testing typical situations is more important than boundary value cases.

Test Data and Test Cases Test data: Inputs which have been devised to test the system. Test cases: Inputs to test the system and the predicted outputs from these inputs if the system operates according to its specification

Testing Effectiveness In an experiment, black-box testing was found to be more effective than structural testing in discovering defects.

Black-box Testing Approach to testing where the program is considered as a black-box. The program test cases are based on specifications. Test planning can begin early in the software process.

Black-box Testing

Equivalence Partitioning

Search Routine Specification procedure Search (Key : INTEGER ; T: array 1..N of INTEGER; Found : BOOLEAN; L: 1..N) ; Pre-condition -- the array has at least one element 1 <= N Post-condition -- the element is found and is referenced by L ( Found and T (L) = Key) or -- the element is not in the array ( not Found and not (exists i, 1 >= i >= N, T (i) = Key ))

Search Routine - Input Partitions Inputs which conform to the pre-conditions. Inputs where a pre-condition does not hold. Inputs where the key element is a member of the array. Inputs where the key element is not a member of the array.

Testing Guidelines (Arrays) Test software with arrays which have only a single value. Use arrays of different sizes in different tests. Derive tests so that the first, middle and last elements of the array are accessed. Test with arrays of zero length (if allowed by programming language).

Search Routine - Input Partitions Array Single value Single value More than 1 value More than 1 value More than 1 value More than 1 value Element In array Not in array First element in array Last element in array Middle element in array Not in array

Search Routine - Test Cases Input array (T) Key (Key) Output (Found, L) 17 17 true, 1 17 0 false,?? 17, 29, 21, 23 17 true, 1 41, 18, 9, 31, 30, 16, 45 45 true, 6 17, 18, 21, 23, 29, 41, 38 23 true, 4 21, 23, 29, 33, 38 25 false,??

Structural Testing Sometime called white-box testing. Derivation of test cases according to program structure. Knowledge of the program is used to identify additional test cases. Objective is to exercise all program statements (not all path combinations).

White-box Testing

class BinSearch { // This is an encapsulation of a binary search function that takes an array of // ordered objects and a key and returns an object with 2 attributes namely // index - the value of the array index // found - a boolean indicating whether or not the key is in the array // An object is returned because it is not possible in Java to pass basic types by // reference to a function and so return two values // the key is -1 if the element is not found public static void search ( int key, int [] elemarray, Result r ) { int bottom = 0 ; int top = elemarray.length - 1 ; int mid ; r.found = false ; r.index = -1 ; while ( bottom <= top ) { mid = (top + bottom) / 2 ; if (elemarray [mid] == key) { r.index = mid ; r.found = true ; return ; } // if part else { if (elemarray [mid] < key) bottom = mid + 1 ; else top = mid - 1 ; } } //while loop } // search } //BinSearch Binary search (Java)

Binary search flow graph

Binary Search - Equivalence Partitions Pre-conditions satisfied, key element in array. Pre-conditions satisfied, key element not in array. Pre-conditions unsatisfied, key element in array. Pre-conditions unsatisfied, key element not in array. Input array has a single value. Input array has an even number of values. Input array has an odd number of values.

Binary Search Equivalence Partitions

Binary Search - Test Cases Input array (T) Key (Key) Output (Found, L) 17 17 true, 1 17 0 false,?? 17, 21, 23, 29 17 true, 1 9, 16, 18, 30, 31, 41, 45 45 true, 7 17, 18, 21, 23, 29, 38, 41 23 true, 4 17, 18, 21, 23, 29, 33, 38 21 true, 3 12, 18, 21, 23, 32 23 true, 4 21, 23, 29, 33, 38 25 false,??