1 CS115 Class 16: Testing (continued) Due today –Review: No Silver Bullet For next time –Deliverable: Unit Tests – one per group member –Review: The New.

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Software Testing. Quality is Hard to Pin Down Concise, clear definition is elusive Not easily quantifiable Many things to many people You'll know it when.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
1 Software Engineering Lecture 11 Software Testing.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
16/27/2015 3:38 AM6/27/2015 3:38 AM6/27/2015 3:38 AMTesting and Debugging Testing The process of verifying the software performs to the specifications.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
CS4723 Software Validation and Quality Assurance Lecture 02 Overview of Software Testing.
1 CS115 Class 15: Testing Due today –User Manual –Software Inspections –Review: Testing Next time –Review No Silver Bullet.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
Chapter 13 & 14 Software Testing Strategies and Techniques
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Terms: Test (Case) vs. Test Suite
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
System/Software Testing
Software Testing. Recap Software testing – Why do we do testing? – When it is done? – Who does it? Software testing process / phases in software testing.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
TESTING.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Introduction Telerik Software Academy Software Quality Assurance.
CMSC 345 Fall 2000 Unit Testing. The testing process.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Chapter 8 – Software Testing Lecture 1 1Chapter 8 Software testing The bearing of a child takes nine months, no matter how many women are assigned. Many.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
Software Testing The process of operating a system or component under specified conditions, observing and recording the results, and making an evaluation.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Neil Ghani Software testing. 2 Introduction In a perfect world all programs fully verified testing thus redundant Back in the real.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Software Testing Yonsei University 2 nd Semester, 2014 Woo-Cheol Kim.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
08120: Programming 2: SoftwareTesting and Debugging Dr Mike Brayshaw.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Testing Data Structures Tao Xie Visiting Professor, Peking University Associate Professor, North Carolina State University
Dynamic Testing.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Test Plans Test Driven Development – Unit test plan first Code coverage Automated Regression built as you go Debug is easier Serves as system doc – Still.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
Testing Data Structures
Software Testing.
Testing Tutorial 7.
CS5123 Software Validation and Quality Assurance
Chapter 13 & 14 Software Testing Strategies and Techniques
Types of Testing Visit to more Learning Resources.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
John D. McGregor Session 9 Testing Vocabulary
Testing and Test-Driven Development CSC 4700 Software Engineering
CSE 303 Concepts and Tools for Software Development
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Java & Testing.
Chapter 7 Software Testing.
Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Testing Slides adopted from John Jannotti, Brown University
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Presentation transcript:

1 CS115 Class 16: Testing (continued) Due today –Review: No Silver Bullet For next time –Deliverable: Unit Tests – one per group member –Review: The New Methodology start thinking about software process –how much “process” do you need? –is waterfall good? is agile better? –for what kind of project? »10 week, UI-intensive, web services, critical infrastructure, evolving requirements,...

2 Standard Testing Questions How shall we generate/select test cases? Did this test execution succeed or fail? How do we know when to stop testing? –budget –bug trends –statement coverage, branch coverage, etc

3 2. Was this test execution correct?

4 What is an Oracle? Oracle = alternative implementation of the spec. Examples of oracles –The “eyeball oracle” Expensive, not dependable, lack of automation –A prototype, or sub-optimal implementation E.g., bubble-sort as oracle for quick sort Program Oracle input output correct output compare

5 Record-and-Replay Oracles Record prior runs Test recording is usually very fragile –Breaks if environment changes anything –E.g., location, background color of textbox More generally, automation tools cannot generalize –They literally record exactly what happened –If anything changes, the test breaks A hidden strength of manual testing –Because people are doing the tests, ability to adapt tests to slightly modified situations is built-in

6 Result Checking Easy to check the result of some algorithms –E.g., computing roots of polynomials, vs. checking that the result is correct –E.g., executing a query, vs. checking that the results meet the conditions Not easy to check that you got all results though ! Program input output check

7 Assertions Use assert(...) liberally –Documents important invariants –Makes your code self-checking –And does it on every execution ! –You still have to worry about coverage May need to write functions that check invariants –zcheck() –compiler directive that checks for zero value of loop count or dimension in statement following (FORTRAN) Opinion: most programmers don’t use assert enough

8 Assert example switch(suit) { case Suit.CLUBS:... break; case Suit.DIAMONDS:... break; case Suit.HEARTS:... break; case Suit.SPADES:... } default: assert false : suit; //programmer believes only four values possible for suit

9 Another assert example for control flow invariant void foo() { for (...) { if (...) return; } assert false; //Execution should never reach this point! }

10 3. How shall we generate/select tests? Could focus on code coverage. What else?

11 Black and White Box Testing Black-Box –Don’t “see inside” to code –Specification/requirements driven –Equivalence class, boundary, & output-driven tests White-Box (sometimes “glass box”) –See “inside the box” –Source code driven –Statement, branch, path coverage

12 Scope Unit –focus on correctness of module, component or class –use both white- and black-box Integration –focus on correctness of composition of units –mostly black-box, some white-box System (entire application) –overall correctness, performance, robustness –black-box Acceptance (purchase/deployment trigger) –fitness for use by single customer –black-box and negotiation Alpha/Beta (market drivers to quality)

13 Random Testing About ¼ of Unix utilities crash when fed random input strings –Up to 100,000 characters –See Fuzz Testing paper on web page

14 A Favorite Bug csh !0%8f ! is the history lookup operator –No command beginning with 0%8f csh passes an error “0%8f: Not found” to an error printing routine Which prints it with printf() Lesson: user input should never go to printf()

15 What Fuzz Says About Unix What sort of bugs does random testing find? –Buffer overruns –Format string errors –Signed/unsigned characters –Failure to handle return codes –Race conditions Nearly all of these are problems with C ! –Mostly fixed in Java –Except for races

16 (Semi-)Exhaustive Testing Folk wisdom –If there is a bug, there is a small test case that exhibits the bug Example –You have a list processing function with a bug –What is the size of the smallest list that exhibits the bug? Answer: probably much closer to 3 than to 1,000,000

17 (Semi-)Exhaustive Testing Idea –Run code systematically on small examples Key is systematic –Try all examples up to a certain size –If data space too large for some values, randomize E.g., all lists of length 5 or less With randomly chosen integer element values

18 Regression Testing Idea –When you find a bug, –Write a test that exhibits the bug, –And always run that test when the code changes, –So that the bug doesn’t reappear Without regression testing, it is surprising how often old bugs reoccur

19 Nightly Build Build and regression test the system regularly –Every night –From SVN document repository Why? Because it is easier to fix problems earlier –Easier to find the cause after one change than after 1,000 –Avoids new code from building on the buggy code Helps build discipline: “test then commit” –but testing may be slow

20 Fault Models “Intuition” –founded on strong understanding/experience of software, this application, and its environment –common faults in particular language, eg buffer overruns in C implementation, eg race conditions in concurrent programs particular environment: OS, UI, FS,... particular design style sociological (management, process, context) Develop through repeated –fault analysis & categorization –trend analysis (bug tracking systems) 80/20 rule: 20% of modules have 80% of errors

21 Testing Exercise A program is required to identify whether a rectangle contains a point –The point is identified by its x-y coordinates –The rectangle is identified by two corner points Draw 3 to 5 interesting cases for this problem –When are two test cases “significantly different”? x1,y1 x2,y2 x,y

22 Equivalence Class Testing Method –Identify the entire input data space –Partition into different equivalence classes –Select a data element from each class –Run test case using this data element Goal of equivalence class testing is to select classes so behavior of SUT can be assumed correct for all data in class if known correct for one data element of class –“fault model”

23 Equivalence Class Test Examples Input space: integers from 1 to 100 –Partition: normal input: [1, 100] error input: [- infinity, 0] [101, infinity] –Test cases: one from each class: -1, 42, 200 Input space: calendar dates –Partition: several dimensions needed here valid and invalid dates, leap years, 30/31 day months,... –Test cases: one from each class

24 Boundary Value Analysis Special case of equivalence class testing Choose equivalence classes Test data is also taken from class boundaries –normally values at either side of each boundary Previous example –partitions: [-infinity, 0] [1, 100] [101, infinity] –boundary values: 0, 1, 100, 101

25 Test Planning Exercise Revisited Reconsider the rectangle problem –Create test cases using equivalence class analysis –Invent a faulty implementation –Are your test cases adequate? x1,y1 x2,y2 x,y

26 Common faults/defects and strategies to use Logical conditions incorrect – equivalence class/boundary conditions Calc in wrong part of loop – branch testing non-terminating loop – branch testing Preconditions not set up – outside of bounds Null conditions not handled – equivalence class/boundary conditions Off-by-one – boundary conditions Operator precedence – inspections Inappropriate algorithm – inspections Numerical algorithm incorrect – boundary conditions Deadlocks/livelocks/race conditions - inspections

27 Summary Testing is hard –If done manually, also very expensive and boring Use inspections! –Will save more time in testing and debugging A number of techniques can make testing effective –Randomized testing –Exhaustive testing on small examples –Regression testing –Nightly build

28 Design for Testability Avoid unpredictable results –No unnecessary non-deterministic behavior Design in self-checking –At appropriate places have system check its own work Asserts –May require adding some redundancy to the code Have a test interface Minimize interactions between features –Number of interactions can easily grow huge –Rich breeding ground for bugs

29 “Best Practices” Session By now, you have now developed some expertise in your particular specialization –(tester, coder, documenter, facilitator) Group by specialization to discuss –what knowledge you’ve gained –what works, what doesn’t –tips to help other teams Short (5min) presentation at end