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

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

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

Ingegneria del Software II academic year: Course Web-site: [

Basic Principles of analysis and testing software

Topics in Software Testing

Part 5. Verification and Validation

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

MONIKA HEINER.

Program Analysis. Program Analysis

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

Software Testing. Testing: Our Experiences

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

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

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

Introduction to Dynamic Analysis

INTRODUCTION TO SOFTWARE ENGINEERING

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

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

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

Regression testing. Whenever you find a bug. Why is this a good idea?

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

Software Testing. Software Testing

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

People tell me that testing is

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

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

Testing: Test design and testing process

Learning objectives. Documenting Analysis and Test. Why Produce Quality Documentation? Major categories of documents

Sample Exam Syllabus

Chapter 9 Quality and Change Management

Software Testing TEST CASE SELECTION AND ADEQUECY TEST EXECUTION

Software Testing CS 408

Pearson Education 2007 Chapter 9 (RASD 3/e)

Write perfect C code to solve the three problems below.

Integration Testing. Conrad Hughes School of Informatics. Slides thanks to Stuart Anderson

Lecture 15 Software Testing

10. Software Testing Fundamental Concepts

Integration Testing. Unit Test vs Integration Testing 1. Unit Testing vs Integration Testing 2. Unit testing: isolation, stub/mock objects

Formal Methods and their role in Software and System Development. Riccardo Sisto, Politecnico di Torino

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

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

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

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

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6!

Examination Questions Time allowed: 1 hour 15 minutes

Bridge Course On Software Testing

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

Software Engineering and Scientific Computing

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

17. Assertions. Outline. Built-in tests. Built-in tests 3/29/11. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

Advanced Software Engineering: Software Testing

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

Software Testing Overview. Simula Research Laboratory Oslo, Norway

Chapter 9. Software Testing

Verification and Validation

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

17. Assertions. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

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

Program Correctness and Efficiency. Chapter 2

Chapter 1: Principles of Programming and Software Engineering

Verification and Validation

Verification and Validation

Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems)

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

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

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

Software Testing and Maintenance

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6!

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

Reading assignment: Reviews and Inspections

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

Part I: Preliminaries 24

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

Page 1. Reading assignment: Reviews and Inspections. Foundations for SE Analysis. Ideally want general models. Formal models

Verification and Validation. Verification and validation

Testing. So let s start at the beginning, shall we

Component-Based Software Engineering TIP

QUIZ #5 - Solutions (5pts each)

CS 520 Theory and Practice of Software Engineering Fall 2018

Program Verification! Goals of this Lecture! Words from the Wise! Testing!

Steps for project success. git status. Milestones. Deliverables. Homework 1 submitted Homework 2 will be posted October 26.

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

Introduction to Software Engineering

Aerospace Software Engineering

CMSC 132: OBJECT-ORIENTED PROGRAMMING II

Second assignment came out Monday evening. Find defects in Hnefetafl rules written by your classmates. Topic: Code Inspection and Testing

Question 1: What is a code walk-through, and how is it performed?

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

Standard Glossary of Terms used in Software Testing. Version 3.2. Foundation Extension - Usability Terms

Integration Testing Qualidade de Software 2

SOFTWARE ENGINEERING SOFTWARE VERIFICATION AND VALIDATION. Saulius Ragaišis.

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

Chapter 8 Software Testing. Chapter 8 Software testing

Chap 2. Introduction to Software Testing

White-Box Testing Techniques

Introduction To Software Testing. Brian Nielsen. Center of Embedded Software Systems Aalborg University, Denmark CSS

Topic: Software Verification, Validation and Testing Software Engineering. Faculty of Computing Universiti Teknologi Malaysia

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

Testing Tools. Software Testing and Verification. Lecture 14. Stephen M. Thebaut, Ph.D. Prepared by. University of Florida

Software Quality. Chapter What is Quality?

Transcription:

Why testing and analysis Software Testing Adapted from FSE 98 Tutorial by Michal Young and Mauro Pezze Software is never correct no matter what developing testing technique is used All software must be verified Software testing is important to control the quality of the product and the process very (often too) expensive Outline A framework for software testing A framework for testing and analysis Overview of software testing Summary Software qualities: identification of dependability properties Validation versus verification: identification of different types of activities Undecidability issues: why is software testing so difficult? Impact of type of software on testing The principles underlying software testing Software Qualities External properties (that can be verified) timeliness. interoperability Dependability properties robustness correctness reliability safety. Process oriented (internal) properties External properties (that can be validated) maintainability reusability user friendliness. modularity. usability Dependability Properties Reliable Correct Robust but not safe: catastrophic failures can occur Robust Safe Safe but not correct: annoying failures can occur Reliable but not correct: failures occur rarely Correct but not safe or robust: the specification is inadequate

Example: Traffic light (USA version) Correctness, reliability: let traffic pass according to correct pattern and central scheduling Validation vs. Verification Actual Requirements Formal descriptions System Control Robustness, safety: Provide degraded function when possible; never signal conflicting greens. Validation Includes usability testing, user feedback Verification Includes testing, inspections, static analysis Verification or validation depend on the specification ever You can t always get what you want Unverifiable (but validatable) spec: if a user presses a request button at floor i, an available elevator must arrive at floor i soon 1 2 3 4 5 6 7 8 Correctness properties are undecidable the halting problem can be embedded in almost every property of interest Example: elevator response Property Verifiable spec: if a user presses a request button at floor i, an available elevator must arrive at floor i within 30 seconds Program Decision Procedure Pass/Fail Getting what you need Easier Properties - Example: Unmatched Semaphore Operations Easier properties Optimistic inaccuracy (testing) Perfect verification We must make the problem of verification easier by permitting some kind of inaccuracy Pessimistic inaccuracy (analysis, proofs) if (. ) lock(s); if ( ) unlock(s); Static checking for match is necessarily inaccurate so Java prescribes a more restrictive, but statically checkable construct. synchronized(s)

Impact of the type of software on testing Different emphasis on the same properties The type of software and its characteristics impact testing in different ways: different emphasis may be given to the same properties different (new) properties may be required different (new) testing techniques may be needed Dependability requirements: differ radically between» Safety-critical applications flight control systems have strict safety requirements telecommunication systems have strict robustness requirements» Mass-market products dependability is less important than time to market can vary within the same class of products:» reliability and robustness are key issues for multi-user operating systems (e.g., UNIX)» less important for single users operating systems (e.g., Windows or MacOS) Different type of software may require different properties Different properties require different testing techniques Timing properties deadline satisfaction is a key issue for real time systems, but can be irrelevant for other systems performance is important for many applications, but is the main issue for hard-real-time systems Synchronization properties absence of deadlock is important for concurrent or distributed systems, not an issue for other systems External properties user friendliness is an issue for GUI, irrelevant for embedded controllers Performance can be analyzed using statistical techniques, but deadline satisfaction requires exact computation of execution times Reliability can be checked with statistical testing techniques, correctness can be checked with weakest precondition computation (to prove the absence of faults) Different testing techniques for checking the same properties for different software Principles Test selection criteria based on structural coverage are different for procedural software (statement, branch, path, ) object oriented software (coverage of combination of polymorphic calls and dynamic bindings, ) concurrent software (coverage of concurrent execution sequences, ) mobile software Principles underlying effective software testing and analysis techniques include: Sensitivity: better to fail every time than sometimes Redundancy: make intentions explicit Partitioning: divide and conquer Restriction: make the problem easier Feedback: tune the testing process

Sensitivity: Better to fail every time than sometimes Redundancy: make intentions explicit Consistency helps: a test selection criterion works better if every selected test provides the same result, i.e., if the program fails with one of the selected tests, it fails with all of them (reliable criteria) Sometimes useful to turn off nondeterminism Redundant checks can increase the probability of catching specific faults early or more efficiently. Static type checking is redundant with respect to dynamic type checking, but it can reveal many type mismatches earlier and more efficiently. Validation of requirement specifications is redundant with respect to validation of the final software, but can reveal errors earlier and more efficiently. Testing and proof of properties are redundant, but are often used together to increase confidence Partitioning: divide and conquer Restriction: make the problem easier Hard testing and verification problems can be handled by suitably partitioning the input space: both structural and functional test selection criteria identify suitable partitions of code or specifications (partitions drive the sampling of the input space) Suitable restrictions can reduce hard (unsolvable) problems to simpler (solvable) problems A weaker spec may be easier to check: it is impossible (in general) to show that pointers are used correctly, but the simple Java requirement that pointers are initialized before use is simple to enforce. A stronger spec may be easier to check: it is impossible (in general) to show that type errors do not occur at run-time in a dynamically typed language, but statically typed languages impose stronger restrictions that are easily checkable. Feedback: tune the development process Outline Learning from experience: checklists are built on the basis of errors revealed in the past error taxonomies can help in building better test selection criteria A framework for testing and analysis Overview of software testing Summary

Testing Goals of testing Testing = executing the program on a sample of input data dynamic technique: programs must be executed optimistic inaccuracy: the program is executed on a (very small) subset on input data, the behavior of the program on every input is assumed to be consistent with the examined behaviors Find faults ( Debug Testing): A Test is successful if the program fails (Goodeneogh, Gerhart, Toward a Theory of Test Data Selection, IEEE Transactions on Software Engineering, Jan. 85) Provide confidence (Acceptance Testing) of reliability of (probable) correctness of detection (therefore absence) of particular faults Testing is not a phase Testing sub-activities Quality assessment and improvement activities are spread through the whole development cycle: from requirements elicitation:» identify qualities,» acceptance test planning to maintenance:» regression test execution» revision of regression test suites Test case execution is only a (relatively small) part of the process Must also consider Test case generation Test result evaluation Planning is essential To achieve early and continuous visibility To choose appropriate techniques at each stage To build a testable product To coordinate complementary analysis and testing Granularity levels Testing activities before coding Acceptance testing the software behavior is compared with end user requirements System testing the software behavior is compared with the requirements specifications Integration testing checking the behavior of module cooperation checking the behavior of single modules Planning acceptance test planning (requirements elicitation) system test planning (requirements specifications) Integration & unit test planning (architectural design) Generation create functional system tests (requirement specifications) generate test oracles (detailed design) generate black box unit tests (detailed design) Regression testing checking the behavior of new releases

Testing activities after coding The scaffolding problem Generation create scaffolding (units) Execution unit test execution (units) integration test execution (subsystems) system test execution (system) acceptance test execution (system) regression test execution (system) Measuring coverage analysis (unit coding) Generation delivery regression test suites (integration and delivery) revise regression tests (maintenance) How to provide the environment for executing the tests scaffolding is extremely important for unit and integration testing scaffolding may require substantial coding effort good scaffolding is an important step toward efficient regression testing The oracle problem The test case generation problem How to inspect the results of executing test and reveal failures Oracles are required at each stage of testing Automated test oracles required when running many tests Oracles are difficult to design - no universal recipe How to generate test data Partition testing: divide program in (quasi-) equivalence classes random functional (black box)» based on specifications structural (white box)» based on code fault based» based on classes of faults White vs black box The termination problem Black box depends on the specification notation scales up (different techniques at different granularity levels) it cannot reveal code coverage problems (same specification implemented with different modules) White box based on control or data flow coverage does not scale up (mostly applicable at unit and integration testing level) cannot reveal missing path errors (part of the specification that is not implemented) How to decide when to stop testing A hard managerial problem when resources (time and budget) are over» no information about the efficacy of testing» BUT resource constraints must be taken into account When some coverage is reached» no assurance of software quality» it can be a reasonable and objective criterion» It can be (partially) automated

Outline Unit Testing: Main Activities A framework for testing and analysis Overview of software testing Summary Detail Design Design inspections Generate oracles Unit test planning Automated design analyses Unit Coding Code inspections Create scaffolding Unit test execution Automated code analyses Coverage analysis Integration & Delivery Integration test execution System test execution Acceptance test execution Deliver regression test suite Maintenance Regression test execution Revise regression test suite Create Scaffolding Generate Drivers and Stubs Goal: set up the environment for executing tests D R I V E R initialization of non-local variables initialization of parameters activation of the unit PROGRAM UNIT templates of modules used by the S T unit (functions called by the unit) U B templates of any other entity used by the unit ORACLE check the correspondence between the produced and the expected result Brute force coding From driver/stub specs interactive: ask user for values automatic: (approximately) compute required values - parsing the unit to partially generate the framework - add scripts to fill in the framework Test-case Generation from Natural Language Structural Coverage Testing cannot be automated some structure (e.g., organization standards) can help guidelines to increase confidence level and reduce discretionality: at least on test case for each: subsets of valid homogeneous data non valid (combinations of) data boundary data specific data (treated independently, error prone,) Adequacy criteria If significant parts of program structure are not tested, testing is surely inadequate Control flow coverage criteria Statement (node, basic block) coverage Branch (edge) coverage Condition coverage Attempted compromise between the impossible and the inadequate

Statement Coverage Branch Coverage int select(int A[], int N, int X) i=0 int i=0; while (i<n and A[i] <X) i<n and A[i] <X if (A[i]<0) A[i]<0 i++; return(1); return(1) i++ One test datum (N=1, A[0]=-7, X=9) is enough to guarantee statement coverage of function select Faults in handling positive values of A[i] would not be revealed int select(int A[], int N, int X) i=0 int i=0; while (i<n and A[i] <X) i<n and A[i] <X if (A[i]<0) A[i]<0 i++; return(1) return(1); i++ We must add a test datum (N=1, A[0]=7, X=9) to cover branch of the if statement. Faults in handling positive values of A[i] would be revealed. Faults in exiting the loop with condition A[i] <X would not be revealed Condition Coverage int select(int A[], int N, int X) i=0 int i=0; while (i<n and A[i] <X) i<n and A[i] <X if (A[i]<0) A[i]<0 i++; return(1) return(1); i++ The Budget coverage criterion Industry s answer to when is testing done When the money is used up When the deadline is reached This is sometimes a rational approach! Implication 1: Adequacy criteria answer the wrong question. Selection is more important. Implication 2: Practical comparison of approaches must consider the cost of test case selection Both conditions (i<n), (A[i]<X) must be false and true for different tests. In this case, we must add tests that cause the while loop to exit for a value greater than X. Faults that arise after several iterations of the loop would not be revealed. Regression Testing Outline Testing a new version (release): how can we minimize effort using results of testing of previous versions? On a previous release: save scaffoldings (drivers,stubs,oracles) record test cases (<inputs,outputs>) On the new release: keep track of changes evaluate impact of changes A framework for testing and analysis Overview of software testing Summary

Testing is Not a Phase Complementary Techniques Quality assessment and improvement activities must be spread through the whole development cycle Planning is essential To achieve early and continuous visibility To choose appropriate techniques at each stage To build a testable product To coordinate complementary analysis and testing techniques There are no silver bullets Different techniques depending on available artifacts Different techniques depending on properties to be ascertained Different techniques depending on acceptable cost and degree of assurance Optimistic inaccuracy (testing) Pessimistic inaccuracy (analysis, proofs) Perfect verification Easier properties Automation Automation is sometimes necessary For some automated static analyses To accurately check large sets of test results and often useful For cost-effective regression testing To monitor coverage, generate some tests automatically But some techniques are practical even without tools Inspections of all artifacts, compilation of checklists, functional test case creation