(1) Verification Methods CS2110: SW Development Methods Reading: Study Section 1.2.5 in the MSD text These slides supplement the textbook – These touch.

Slides:



Advertisements
Similar presentations
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Advertisements

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.
Practical Testing Techniques. Verification and Validation Validation –does the software do what was wanted? “Are we building the right system?” –This.
1 Software Engineering Lecture 11 Software Testing.
Well-behaved objects 4.0 Testing. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to.
Software Testing. Overview Definition of Software Testing Problems with Testing Benefits of Testing Effective Methods for Testing.
Illinois Institute of Technology
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Understand.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
System/Software Testing
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Slide 6.1 CHAPTER 6 TESTING. Slide 6.2 Overview l Quality issues l Nonexecution-based testing l Execution-based testing l What should be tested? l Testing.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
CS 217 Software Verification and Validation Week 6, Summer 2014 Instructor: Dong Si
CMSC 345 Fall 2000 Unit Testing. The testing process.
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.
Lecture 11 Testing and Debugging SFDV Principles of Information Systems.
Introduction to Testing 1. Testing  testing code is a vital part of the development process  the goal of testing is to find defects in your code  Program.
CSE 219 Computer Science III Testing. Testing vs. Debugging Testing: Create and use scenarios which reveal incorrect behaviors –Design of test cases:
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.
COMP 121 Week 1: Testing and Debugging. Testing Program testing can be used to show the presence of bugs, but never to show their absence! ~ Edsger Dijkstra.
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Black-box Testing.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
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.
The Software Development Process
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
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.
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.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
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
 Software Testing Software Testing  Characteristics of Testable Software Characteristics of Testable Software  A Testing Life Cycle A Testing Life.
Dynamic Testing.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Testing JUnit Testing. Testing Testing can mean many different things It certainly includes running a completed program with various inputs It also includes.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
SOFTWARE TESTING SOFTWARE TESTING Presented By, C.Jackulin Sugirtha-10mx15 R.Jeyaramar-10mx17K.Kanagalakshmi-10mx20J.A.Linda-10mx25P.B.Vahedha-10mx53.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
CSC 108H: Introduction to Computer Programming
Software Testing.
Rekayasa Perangkat Lunak Part-13
John D. McGregor Session 9 Testing Vocabulary
Verification and Testing
John D. McGregor Session 9 Testing Vocabulary
Testing UW CSE 160 Spring 2018.
John D. McGregor Session 9 Testing Vocabulary
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Presentation transcript:

(1) Verification Methods CS2110: SW Development Methods Reading: Study Section in the MSD text These slides supplement the textbook – These touch on other important methods, but focus on execution-based testing

(2) Some Definitions Verification: showing that something meets specifications –We verify “against” something –Important: if you don’t have requirements specifications documented, then you can’t verify! –If behavior is not defined, then what counts as incorrect behavior? Verification can happen on any kind of software work- product –designs, code, etc.

(3) Verification Techniques At least four approaches to verifying code quality: 1.Execution-based Testing (running tests) 2.Inspections –People examine the work product by eye 3.Static Analysis by a tool –For C programs, an old tool called “lint” –For Java programs, some nice tools integrate with Eclipse: CheckStyle and PMD 4.Formal Correctness Proofs –Use mathematics to demonstrate the desired property

(4) Execution-based Testing Some Basic Definitions: Fault: What we think of as a bug –Something in the code that’s wrong Failure: Observed incorrect behavior of a system resulting from a fault Error: Mistake made by a developer A possible definition of execution-based testing: –Process of inferring certain behavioral properties of a product based, in part, on results of executing it in a known environment with selected inputs.

(5) Famous and Important Quote Program testing can effectively show the presence of bugs but is hopeless for showing their absence. –Edsger Dijkstra –Famous computer scientist –Turing Award winner –Wrote "Go To Statement Considered Harmful“ (1968) –Shortest-path algorithm

(6) Types of Testing Unit testing –An individual class or function is tested thoroughly –Done as part of coding process –Done by the programmer him/herself –Usually by a test harness (or driver) or using a test-class Integration testing –Multiple parts of a system are combined and tested to see if they work together Acceptance testing –The customer is involved. (Alpha or beta testing)

(7) Approaches to Unit Testing Two approaches –Test only based on inputs, outputs (i.e. the specification) without looking at the code –Test based on the logic of the code (must study it) The 1 st of these is called black-box testing The 2 nd of these is glass-box or white-box testing Some principles of glass-box testing –Make sure every line (or “case”) gets executed –Make sure loops get done zero times, >zero times –Etc.

(8) Limitations of Glass-Box Testing Why not fully exercise our code? Logic of a piece of code defines a set of possible execution paths, “flow-paths,” through the function –Think of a flow-chart –The inputs control which path is taken A good set of test data might make sure every possible path is followed –This tests every possible behavior Problem: for even small programs with loops and conditionals, the total number of paths becomes too large too quickly –See MSD text, p

(9) Black-Box Testing This means testing based on inputs to the code- module without basing tests on code’s internals –You can’t see inside a black-box –Note: MSD’s definition on p. 26 isn’t the usual one Choose test cases for common problems –Boundary values, boundary conditions –Off-by-one errors –Incorrect inputs Important: You have to know in advance what the expected result of any test should be!

(10) Lab on Monday/Tuesday The JUnit (v. 3) framework is a tool to help people generate and format unit tests in a systematic way. Stand-alone and also built into Eclipse Example JUnit test –Class contains all tests –setUp() performs preconditions –“test…” is an individual test case –“assert” checks a program condition public class CoffeeMakerTest extends TestCase { private CoffeeMaker cm; private Recipe recipe1; public void setUp() { cm = new CoffeeMaker(); recipe1 = new Recipe(); recipe1.setName("Coffee"); recipe1.setPrice(50); recipe1.setAmtCoffee(6); recipe1.setAmtMilk(1); } public void testAddRecipe() { assertTrue(cm.addRecipe(recipe1)); }

(11)

(12) When we test a class’ method to see if its loop goes to size-1 and not size, is this clearly an example of: 1.A black box test 2.A glass-box test 3.A unit test 4.Both 1 and 3 5.Both 2 and 3

(13) Planning Your Tests How do we plan a “test case”? Define three parts first: –A purpose (why are we doing this particular test?) –An input –An expected result We execute the test to see if observed output matched the expected result –It’s really just like a scientific experiment When testing, have a plan (at least in your head) –Don’t test blindly or randomly

(14) Planning Your Tests Poorly specified test cases… Test IDDescriptionExpected Results Actual Results 1Player 1 rolls dice and moves. Player 1 moves on the board. 2Player 2 rolls dice and moves. Player 2 moves on the board.

(15) Planning Your Tests Why are these test cases better than the previous ones? Test IDDescriptionExpected Results Actual Results 1Precondition: Game is in test mode, GameBoard is loaded, and game begins. Number of Players: 2 Player 1 dice roll: 3 Player 1 moves to square Blue 3. 2Precondition: TestID 1 completed successfully. Player 2 dice roll: 3 Player 2 moves to square Blue 3.

(16) Unit Testing: Boundary values Often programs misbehave because we make mistakes dealing with the “extremes” Examples: –The last item or first item in a collection –The start or end of a range of values Equivalent classes of test cases –Don’t have test cases or data that test the same situation (e.g. the middle of a range) Boundary or extreme conditions –An empty list, an empty file –One item in a list or file

(17) Unit Testing: Off-by-one errors Related to boundary conditions Using the nth value instead of n-1 Using 0 instead of 1 Executing a loop body once when it the body should not be executed at all –Wait – is this one a black-box testing method? Why or why not? Etc.

(18) Unit Testing: Invalid Inputs Rely on pre-conditions defined for your functions –They specify what the agreement is about what you are responsible for when its time to handle mis-use If a function is mis-used in this way –Return an error condition if the interface provides a way to do this –Otherwise, halt program! Better than producing unexpected results Use assertions (more later!)

(19) Example: Program with Student and Course classes Homework 1 this term –Define class Student methods include: –Define class Course methods include: Focus on defining: –Black-box test-cases for the method boolean drop(Course c) in class Student Let’s make a list of possible test-cases for this method!

(20) Example of Full Test-Case Description Test Case #1: Drop last course in list with >1 item –Purpose: Drop Course c for Student s where that course is the last course stored in the Student object's courses list. This tests the boundary condition of last item in list for Student.drop(c). –Input: Student s is enrolled in three courses, and the course to be dropped is the last of these stored in the list. –Expected output: The Student s is unchanged except that only two courses are stored for that student. Also, the list of students stored for that course is altered by having that student removed.

(21) Other Test Cases for this Program There are a lot! Boundary conditions? –for Student.drop(): end of list, start of list –same for Course.drop() –Question: affected by whether you used ArrayList instead of Java arrays? –Note: also test “typical” case, item in middle of list –Empty lists: Course.cancel(), Student.dropAll() Off-by-one errors? –Really included in boundary condition testing here

(22) Other Test Cases for this Program Invalid inputs? –See the specifications! –Test return values For boolean, test both success and failure Remember: make it fail! Test of equals() methods? –If you get this wrong, trouble! –Easy to test. (Easy to forget to.)

(23) Good or Bad Test? 1.Good Test? 2.Poor Test? Student s adds a course and the course appears in the schedule

(24) Good or Bad Test? 1.Good Test? 2.Poor Test? Student s currently is in the system and currently has no courses. Student s adds a course number 394 and it appears at the end of the schedule.

(25) Good or Bad Test? 1.Good Test? 2.Poor Test? Student s has 4 courses, drops 3, adds 1. Check if the student is then deleted from the system.

(26) Extra Slides

(27) #2: Inspections: We Might See These Later Many different “styles” or approaches –Walk-throughs, Inspections Advantages: –You can inspect all of a product but usually it is impossible to test all of a product. –Applicable to all work products (e.g. code, designs, requirements documents, etc.) –Fairly easy: training, application, follow-up Disadvantages: –Staff time is expensive –Works best if follows a rigorous process