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

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

Static Analysis! Prof. Leon J. Osterweil! CS 520/620! Fall 2012! Characteristics of! System to be! built must! match required! characteristics!

Formal Verification! Prof. Leon Osterweil! Computer Science 520/620! Spring 2012!

Coding and Testing. Class Schedule rest of semester

Coding and Testing. The Coding Phase. Coding Goal: Create code that can be executed on a computer! What makes a programming language good?

Analysis! Some Examples of Relations!

Part 5. Verification and Validation

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

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

Formal Verification! Prof. Leon Osterweil! Computer Science 520/620! Spring 2011!

Verification and Validation

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

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

Static Analysis! Summary of Dynamic Testing! Some References for Testing! Prof. Leon J. Osterweil! CS 520/620! Spring 2013! DEVELOPMENT PHASES!

(From Glenford Myers: The Art of Software Testing)

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

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

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

Static Analysis! Prof. Leon J. Osterweil! CS 520/620! Spring 2013! Characteristics of! System to be! built must! match required! characteristics!

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

Software Testing. Software Testing

Lecture 15 Software Testing

Testing. ECE/CS 5780/6780: Embedded System Design. Why is testing so hard? Why do testing?

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

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

Topics in Software Testing

Introduction to Dynamic Analysis

Part I: Preliminaries 24

ΗΜΥ 317 Τεχνολογία Υπολογισμού

Software Testing. Testing: Our Experiences

MONIKA HEINER.

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

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

Verification and Validation

Verification and Validation

Quality Assurance in Software Development

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

Chapter 8 Software Testing. Chapter 8 Software testing

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

! Use of formal notations. ! in software system descriptions. ! for a broad range of effects. ! and varying levels of use. !

Bridge Course On Software Testing

INTRODUCTION TO SOFTWARE ENGINEERING

Program Analysis. Program Analysis

Testing & Continuous Integration. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 20 03/19/2010

Verification and Validation. Verification and validation

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

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

ECE 587 Hardware/Software Co-Design Lecture 11 Verification I

Software Testing. Massimo Felici IF

Aerospace Software Engineering

Is Power State Table Golden?

Announcements. Testing. Announcements. Announcements

linaye/gl.html

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

MTAT : Software Testing

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

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

Programming Embedded Systems

Black-box Testing Techniques

Introduction to Software Testing Chapter 5.1 Syntax-based Testing

Testing: Coverage and Structural Coverage

CIS 890: Safety Critical Systems

Testing & Symbolic Execution

10. Software Testing Fundamental Concepts

What is Mutation Testing?

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

CS 520 Theory and Practice of Software Engineering Fall 2018

Introduction to Formal Methods

Simulink 모델과 C/C++ 코드에대한매스웍스의정형검증툴소개 The MathWorks, Inc. 1

Chapter 9. Software Testing

Testing, Fuzzing, & Symbolic Execution

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

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

Testing Role in Unified Approach Coverage: Structural/Coverage Model Based Test Generation from Model Checking (project) Interaction of

Sample Question Paper. Software Testing (ETIT 414)

Chapter 10. Testing and Quality Assurance

Darshan Institute of Engineering & Technology for Diploma Studies

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Outline. software testing: search bugs black-box and white-box testing static and dynamic testing

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

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

CS/ECE 5780/6780: Embedded System Design

Introduction to Software Testing

The testing process. Component testing. System testing

Monitoring Interfaces for Faults

Object-Oriented and Classical Software Engineering

Object-Oriented and Classical Software Engineering

Subject Software Testing Structural Testing

Computational Systems COMP1209

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

CS 161 Computer Security

1: Introduction to Object (1)

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

Lecture Notes on Contracts

Numerical Methods in Scientific Computation

COS 320. Compiling Techniques

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

System Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements

Software Quality Assurance. David Janzen

Chapter 8. Achmad Benny Mutiara

Transcription:

Testing Prof. Leon Osterweil CS 520/620 Spring 2013 Relations and Analysis A software product consists of A collection of (types of) artifacts Related to each other by myriad Relations The relations are essentially desiderata At least initially Before the product can be trusted, the relations need to be verified/confirmed That is the role of analysis Does the software do what it is supposed to do? What are its capabilities and its strengths? What is the nature of the artifact(s) that have been built? What can I count on? What should I worry about?

Requirements Spec. Design Hi Level consistent views Low level Test Plan Code Some Examples of Relations Executing this code must meet this requirement This code must conform to that design element This compiled code came from this compiler This design element addresses those requirements These lower level requirements are elaborations of these higher level requirements This is the date by which that test must be passed Component invocations conform to component abstract interface specifications Documentation describes the actual system ETC..

We now examine the ways in which consistency is defined and determined through the use of relation specifications Requirements Spec.???????????? Test Plan????? Design Hi Level??????? Low level Code

Relation verification should take place continuously through development Analysis should occur continuously from the start: requirements validated against user needs requirements shown internally consistent validate current artifacts against user needs use information from previous analyses to verify current artifacts Test plans should begin with requirements and be reviewed and refined with each phase test plans should be executed as early as possible More details coming up soon Requirements Spec. Design Test Results must match required behavior Characteristics of System to be built must match required characteristics Hi level design must show HOW requirements can be met Hi Level consistent views Low level Code must implement design Test plan exercises this code Test Plan Code

Basic Notions and Definitions Consistency determination is fundamental Specific relations start out as statements of intent Product "has" these qualities if its behavior is consistent with (satisfies) statements of intent Basic Definitions: failure: inconsistency between actual behavior of software and specification of intent fault: software flaw whose execution caused the failure error: human action that results in software containing a fault What are V and V? Informal Requirements Validation Formal Specifications Verification Software Implementation Verification: Is this software right? Validation: Is this the right software?

More Definitions Testing: The systematic (?) search of a program's execution space for the occurrence of a failure More Definitions Testing: The systematic (?) search of a program's execution space for the occurrence of a failure Debugging: Searching for the fault that caused an observed failure

More Definitions Testing: The systematic (?) search of a program's execution space for the occurrence of a failure Debugging: Searching for the fault that caused an observed failure Analysis: The static examination of a program's textual representation for the purpose of inferring characteristics More Definitions Testing: The systematic (?) search of a program's execution space for the occurrence of a failure Debugging: Searching for the fault that caused an observed failure Analysis: The static examination of a program's textual representation for the purpose of inferring characteristics Verification: Using analytic inferences to formally prove all executions of a program are consistent with specifications

More Definitions Testing: The systematic (?) search of a program's execution space for the occurrence of a failure Debugging: Searching for the fault that caused an observed failure Analysis: The static examination of a program's textual representation for the purpose of inferring characteristics Verification: Using analytic inferences to formally prove all executions of a program are consistent with specifications Validation: Using any means possible to confirm that the software is solving the stakeholders problem(s) The Essence of Analysis COMPARISON of BEHAVIOR to INTENT INTENT - Originates with requirements - Different types of intent (requirements) BEHAVIOR - Can be observed as software executes - Can be inferred from execution model - Different models support different inferences COMPARISON - Can be informal--done by human eyeballs - Can be done by computers (comparing text strings) - Can be done by formal machines (eg. FSM's) - Can be done by rigorous mathematical reasoning Results obtained will vary as a function of the above

The Framework Specification of " Intended Behavior " Development" (Synthesis)" Process" Specification of " Actual Behavior" Evaluation" (Analysis) " Process" Testing/Analysis Results" Comparison of Behavior to Intent (relation checking)" (Dynamic) Testing Behavior determined by examining test execution results Intent derived (somehow) from (various) specifications Comparison typically has been done by text examination Although much more automatic testing done now Testing is aimed at discovering the presence of faults By discovering failures And using debugging to trace them to faults Testing should select test cases likely to reveal failures

Dynamic Testing Specification of Intended Behavior Required" Outputs" Test " Execution" Results" Specification of Actual Behavior Result " Comparator" (Human or" Machine)" Comparison of Behavior to Intent Failure" Reporting" Examples of Goals for Testing Does the software do what it is supposed to do? When might it fail? How fast does it run? How accurate are the results? What are its failure modes and characteristics? What can I count on? What should I worry about? What are its strengths and weaknesses? Should be driven by requirements and Software product well-formedness specifications

Testing is too long and hard to do all at once at the end of development Divide the job into subtasks Do some activities during development Can do test planning during development And should do so May reduce or eliminate the need for some post-coding testing Phase testing at the end Using test plans previously developed Testing Phases Unit/Module Comparing a code unit or module with design specifications. planned during coding: done after coding Integration Systematic combination of software components and modules planned during design: done after unit/module V&V Software System Comparing entire software system with requirements planned during requirements: done after integration System Comparing integrated hardware/software system to requirements planned during informal requirements: after SW System

DEVELOPMENT PHASES Requirements Specification Architecting Implementation Designing Coding System Test Plan Software Sys. Test Plan TEST PLANNING Integration Test Plan Unit Test Plan System Testing Software Sys Testing Integration Testing Unit Testing TESTING PHASES Flow of control edge (the ImmFol relation) Data Flow edge (artifacts flow from tail to head) A better representation

A better representation Testing focuses on how to do these Where Requirements Looks Like This Copyright L.J.Osterweil Copyright All Rights L. Osterweil, reserved all rights reserved

Where Requirements Looks Like This And testing is Done here Copyright L.J.Osterweil Copyright All Rights L. Osterweil, reserved all rights reserved Analogous View of Design 10 High-Level Design X 9 ~ Rqmts OK 8 Requirements 6 Declare and Define HLDesign Elements 4 HLDesign OK 7 ~ A Rqmt OK Develop Rqmt Element Declare HLDesign Elements 2 + 5 ~ HLD OK High-Level Design 1 Declare HLDesign Element 3 Define HLDesign Elements Copyright L.J.Osterweil Copyright All Rights L. Osterweil, reserved all rights reserved

Coding Develop Code Modules X Coding Too ~Rqmts OK ~HLD OK Requirements Define Module Interfaces = + Define A Module Interface Interface OK Code All Modules Code OK ~LLD OK High-Level Design Low-Level Design ~Code OK ~ A Rqmt OK Coding Develop Rqmt Element Copyright L.J.Osterweil Copyright All Rights L. Osterweil, reserved all rights reserved Black Box vs. White Box Testing SELECTED INPUTS RESULTANT OUTPUTS DESIRED OUTPUT BLACK BOX TESTING SELECTED INPUTS RESULTANT OUTPUTS INTERNAL BEHAVIOR DESIRED OUTPUT SOFTWARE DESIGN WHITE BOX TESTING (CLEAR BOX TESTING)

Testing Input Space" Program " Output Space" Testing is Sampling the Input Space Key problem: What is the input space? What is the software intended to do? Subproblem: The input space is large One dimension for each program input Each dimension can have as many elements as there are legal inputs (eg. 2**32 different integers) Each input really is different How different? Which differences matter? Key Problem: How to sample from this input space?

What is the input space? Specification" sum_of_roots takes an arbitrarily long sequence of real numbers, and computes the sum of their square roots. The real number sequence must be ended with the number 9999.99 Implementation Program sum_of_roots; Real sum, x, r; sum := 0; Do forever input x; if x = 9999.99 then exit else r := sqrt(x); sum := sum + r; end do; print sum; end; Computing the Input Space There are ~2**32 possible different values for each input If n values are read in, then there are (2**32)**n different points in the input space The number of different input values read in is unlimited There is no limit (theoretically) to the size of the input space

Some observations about the example program input space There is no real need to test every possible combination of input values Most executions behave the same But some input combinations are different Negative values will produce a failure There is a virtually limitless number of inputs that don t cause the negative square root failure A sufficiently large sequence of input values will cause an overflow failure Effective selection of test cases requires thought and care" The Testcase Selection Problem Testing lets you put your program under a microscope Can examine minutiae But only for current execution To find faults you need to select test data to cause failures Testing can demonstrate the presence of faults (when suitable test cases are selected) But demonstrating the absence of faults requires knowing the behaviors of all executions But there are (virtually) infinitely many possible executions So how to sample the inputs representatively?

Partitioning the Input Space Rationale: All points in the same subdomain are processed equivalently by the program But: How to determine the partition? How to know how far the equivalence holds? How to select the point(s) within each domain to use as the actual input(s)? The manual and/or requirements specification can help Equivalence Partitioning The typical approach A test of any value in a given class is equivalent to a test of any other value in that class If a test case in a class reveals a failure, then any other test case in that class should reveal the failure Some approaches limit conclusions to some chosen class of faults and/or failures

Testing Input Space" Program " Output Space" Input Space Partitioning Program " Input Space Divided into Domains"

Structural (White Box) Testing Testcase choices driven by program structure Flowgraph is most commonly used structure: Represent statements by nodes If a statement can execute immediately after another, connect the nodes representing them by an edge Every program execution sequence is a path Criteria based on coverage of program constructs All statements (node coverage) All control transitions (edge coverage) All possible paths, loop iterations (path, loop coverage) How to generate input data to do this? What exact data sets are used to force these coverages? It matters Rigorously defined Flowgraph helps totalpay := 0.0; for i = 1 to last_employee if salary[i] < 50000. then salary[i] := salary[i] * 1.05; else salary[i] := salary[i] * 1.10; totalpay := totalpay + salary[i]; end loop; print totalpay; totalpay := 0.0; for i = 1 to last_employee salary[i] := salary[i] * 1.05 if salary[i] < 50000. salary[i] := salary[i] * 1.10 Different paths partition the execution space totalpay := totalpay + salary[i] end loop print totalpay

Using Flowgraphs to Partition Input Space Requires use of static analysis (described soon) Use program branching conditions to create sets of constraints Solving constraints for each path yields the input domain that forces execution down that path Called Symbolic Execution More on this soon How to assure testing is thorough? Assure every node is covered by at least one test case (node coverage/statement coverage) Assure every edge is covered by at least one test case (edge coverage/branch coverage) Assure every loop is exercised Both by iteration and fall-through Assure all execution paths are covered Practical impossibility And there are many other criteria"

Functional (Black Box) Testing Specification of Intent: Expressed explicitly Increasingly completely» Functionality, timing, accuracy, robustness,... Increasingly rigorously» Mathematics, FSA s Ideally arise directly from requirements and design specifications Comparison With automatic comparators Specification of Behavior Tools to capture test outputs (inputs too) Examples of Black Box Testing Goals Does the software do what it is supposed to do? When might it fail? How fast does it run? How accurate are the results? What are its failure modes and characteristics? What can I count on? What should I worry about? What are its strengths and weaknesses?

Functional (Black Box) Testing Guidelines Result in many test cases Some test cases may satisfy many heuristics Keep track of the goal of each test case Changes in specification will cause changes in functional test cases Need a way to organize, use, reuse, and monitor functional testing NOTE: many of the functional testing guidelines can also be applied in structural testing (at a more detailed and formal level) Assertion-Based Testing Zoom in on internal workings of the program Examine behaviors at internal program locations while the program is executing Augments examining only final outputs Assertions: Specifications of intended properties of execution state (e.g. relations among the values of program variables) Development of increasingly elaborate assertion languages Often: Checking relations between code and design Comparison: Runtime evaluation of assertions Facilities for programming reactions to violations Also useful as a debugging aid

Inserted by" Tester" <code sequence>" X := Y;" Time := Y * 2.0 * T;" ASSERT Time > 0.0;" <rest of code>" " " Automatically " processed" into" if ~(Time > 0.0) Then" "Assertion_violation_handler;" Assertion-Based Dynamic Testing Specification of " Intended Behavior " Specification of " Actual Behavior" Functional" Behavior" Assertions" Intermediate" Execution " Results " Runtime " Assertion" Checking" Reports on" Internal Failures" Comparison of Behavior to Intent"

Functional vs. Structural Testing Cannot determine if software does what it is supposed to do without considering the intent a special case not handled by the implementation will not be tested unless the specification/ requirements are considered Cannot ignore what is actually done by the software program may treat one element in domain differently than stated in the specification implementation often employs use an algorithmic technique with special characteristics that are not highlighted in the specification Both functional and structural testing must be done Should use all available information in testing How much testing is enough?

How much testing is enough? Test programs by running data through them Does the program select correct answers? Reject incorrect ones How much testing is enough? Test programs by running data through them Does the program select correct answers? Reject incorrect ones Test test datasets by running progams through them Can the testsets separate the correct programs from the MUTANTS?

Mutation Testing Determines the adequacy of sets of testcases Theory Testsets should be sufficient to pick up all faults In order for a testset to be adequate one of its testcases must differentiate between correct code and code with a fault Mutation Testing Approach Produce a family of mutants of the original program Use it to test the adequacy of the program s testcase set: Run mutants and original program over the set Make sure some testcase produces different results If not, make sure mutants didn t really change the program If it did, then add a new testcase that forces different results

original Start with program to be tested original mutants Create mutants

How to build mutants The competent programmer assumption Mutants are simple coding errors Change each integer to another Change each loop iteration count (by 1) Misspell each variable name Change each arithmetic operator Etc. More complicated mutants seem unnecessary Multiple mutants seem unnecessary * Example: original mutants Change x := a + b To x := a - b Create a mutant

* original mutants Create a mutant @ original? # = +, mutants - * Continue to create more mutants

So, how does this work? original mutants Start with all mutants

testcases original mutants Consider a set of testcases testcases original mutants Run each testcase through all mutants

testcases original mutants comparator Compare mutant output to original output testcases & original mutants ~ = comparator If results differ then kill the mutant

testcases original mutants Continue for all testcases testcases original A good set of testcases kills all mutants

Note, however, that, for example: a test set where b = 0 will not kill the mutant created by replacing x := a + b with x := a - b Mutation testing A fun idea Lots of interest in this over the decades Still not a particularly practical idea So what do we do instead?

Summary of Problems in Doing Testing Effectively Hard to cover program execution space effectively Hard to select test data effectively Hard to tell if test results are right or wrong --if program computes complex function(s) --if the number of test cases gets large Best to detect errors early--before they become faults Testing comes at the end of the lifecycle, when time and budget tend to be short What do you know when testing is done? What relations have been checked? How thoroughly? To whose satisfaction? Summary of Dynamic Testing Strengths: Microscopic examination of execution details Evaluation in actual runtime environment Oldest approach, most familiar Weaknesses: Cannot demonstrate absence of faults Hard to generate test data Hard to know when testsets are adequate Testing aids (eg. assertion checkers) alter execution

Static Analysis Technique for demonstrating the absence of faults without the need for execution Specification of Intent: derived from requirements Specification of Behavior: derived from model(s) Comparison: Done analytically and mathematically Results: Theorems about the program (eg. proofs that certain behaviors are impossible--or mandatory)