Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.

Slides:



Advertisements
Similar presentations
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Advertisements

Software testing.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing 2.
Software Engineering Software Testing.
CS 425/625 Software Engineering Software Testing
Testing an individual module
Chapter 18 Testing Conventional Applications
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Systems Verification and Validation Laboratory Assignment 3
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Software Engineering Modern Approaches
Software Engineering Modern Approaches
Testing phases. Test data Inputs which have been devised to test the system Test cases Inputs to test the system and the predicted outputs from these.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Software testing techniques 3. Software testing
UNIT TESTING. Plan project Integrate & test system Analyze requirements Design Maintain Test units Implement Software Engineering Roadmap Identify corporate.
Software Engineering Chapter 23 Software Testing Ku-Yaw Chang Assistant Professor Department of Computer Science and Information.
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.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
© Andrew IrelandSoftware Design F28SD2 Software Design (F28SD2): Life-Cycle Perspective - Part 2 Andrew Ireland School of Mathematical & Computer Sciences.
Chapter 13: Implementation Phase 13.3 Good Programming Practice 13.6 Module Test Case Selection 13.7 Black-Box Module-Testing Techniques 13.8 Glass-Box.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Contents Introduction Requirements Engineering Project Management
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
1 Phase Testing. \ 2 Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine subphases) Define Coding Standards.
CS /51 Illinois Institute of Technology CS487 Software Engineering Software Testing Techniques Mr. David A. Lash.
Testing Worshop in Software Engineering Project Department of Computer Science Ben-Gurion university 1Worshop in SE ProjectSpring 2013.
Software Testing. 2 CMSC 345, Version 4/12 Topics The testing process  unit testing  integration and system testing  acceptance testing Test case planning.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
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.
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.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
Software Construction Lecture 18 Software Testing.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
CSC 480 Software Engineering Testing - I. Plan project Integrate & test system Analyze requirements Design Maintain Test units Implement Software Engineering.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
© 2010 John Wiley & Sons Ltd. Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
CS451 Lecture 10: Software Testing Yugi Lee STB #555 (816)
is a validation process
Testing Data Structures Tao Xie Visiting Professor, Peking University Associate Professor, North Carolina State University
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Dynamic Testing.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Testing Worshop in Software Engineering Project Department of Computer Science Ben-Gurion university 1Worshop in SE ProjectSpring 2013.
8. UNIT TESTING. Plan project Integrate & test system Analyze requirements Design Maintain Test units Implement Software Engineering Roadmap: Chapter.
Defect testing Testing programs to establish the presence of system defects.
SOFTWARE TESTING AND QUALITY ASSURANCE. Software Testing.
Testing It is much better to have a plan when testing your programs than it is to just randomly try values in a haphazard fashion. Testing Strategies:
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Software Engineering Modern Approaches
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Chapter 10 – Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Guide for writing a Software Testing Document
Whitebox Testing.
CSE 1020:Software Development
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1

Chapter 26: Unit Testing 2

Learning Goals of This Chapter What parts of the code should be subjected to unit testing? How do you go about unit testing? What is statement coverage? Branch coverage? Path coverage? How does equivalence partitioning help in selecting test cases? How do you use stubs when the unit under test requires other – but unbuilt – units? How do you use JUnit? What is test-driven development? How is unit testing done in case studies? Requirements analysis Design Implementation Testing Maintenance Planning The Software Development Lifecycle Phase most relevant to this chapter is shown in bold 3

The Source of a Unit’s Specification Requirement document (SRS) Design document (SDD) Implementation unit (code for method or class) Implementation-time specification Key: “specifies” Example: “It shall be possible to add a DVD to the video store’s inventory” Example: method addDVD( … ) “Preconditions: …. Postconditions: …” Example: void setDVDName( … ) Example: get DVD title Domain classes © 2010 John Wiley & Sons Ltd. 4

Relating Tests to Requirements & Design (1) D-Requirements 3.2.EC.1.2 Qualities of Encounter characters Every game character has the same set of qualities. Each quality shall be a non- negative floating point number with at least one decimal of precision.... Characters GameCharacter EncounterCharacter adjustQuality() (2) Design GameCharacter: An abstract class with attribute name against this requirement Test this method... Test this class against this requirement Encounter Characters © 2010 John Wiley & Sons Ltd. 5

Unit Test Methods White-Box Methods Statement coverage Test cases cause every line of code to be executed Branch coverage Test cases cause every decision point to execute Path coverage Test cases cause every independent code path to be executed Black-Box Methods  Equivalence partitioning Divide input values into equivalent groups  Boundary Value Analysis Test at boundary conditions © 2010 John Wiley & Sons Ltd. 6

Program Control Graph of computeFine() False True False © 2010 John Wiley & Sons Ltd. 7

Branch Coverage of computeFine() Test Case #1 False True False True Test Case #2 False True False True © 2010 John Wiley & Sons Ltd. 8

Distinct Paths of computeFine() Path #1 False True False True Path #3 False True False True Path #2 False True False True Path #4 False True False True © 2010 John Wiley & Sons Ltd. 9

Test Cases for Distinct Paths of computeFine() Test Case #daysLateprintONPath 11TRUE FALSE FALSE TRUE © 2010 John Wiley & Sons Ltd. 10

Program Control Graph for computeFines() False True True False © 2010 John Wiley & Sons Ltd. 11

Basis Paths for computeFines() Basis Path #1 False True True False Basis Path #2 False True True False Basis Path #4 False True True False Basis Paths #3 False True True False © 2010 John Wiley & Sons Ltd. 12

Parameter Space of computeFine() old releases one-of-a-kind new releases Days late e.g., (6 days late, “Casablanca”) Each element represents a pair: ( Days late, Movie name ) © 2010 John Wiley & Sons Ltd. 13

0 new release Days late 5 One Equivalence Partition of computeFine() © 2010 John Wiley & Sons Ltd. 14

Equivalence Partitions of computeFine() Method old release one-of-a-kind new release Days late 5 New release DVD’s 6-15 days late © 2010 John Wiley & Sons Ltd. 15

Using Equivalence Partitions to Create Test Cases Test … … values strictly within each region … values at region borders Notes: Include all illegal regions Within each constraint, select randomly –E.g., With “new release” input, select lateness days at random betw. 6 & 15, excluding 6 & 15 © 2010 John Wiley & Sons Ltd. 16

RentalItem neededByRent() Using Stubs to Test a Method Rental rent() RentalCustomer neededByRent() RentalItem neededByRent() for testing dependence Rental rent() RentalCustomer neededByRent() stubbed © 2010 John Wiley & Sons Ltd. 17

Partitioning adjustQuality() Top Level © 2010 John Wiley & Sons Ltd.

Partitioning adjustQuality(): “Within Range” © 2010 John Wiley & Sons Ltd.

Partitioning adjustQuality(): On Boundary © 2010 John Wiley & Sons Ltd.

Test-Driven Development 1, 2. Write a test case (will fail) 3. Write/fix code to pass test 4. Run test case Test passes, more tests to be written Test passes, no more tests to be written Test fails © 2010 John Wiley & Sons Ltd. 21

Output of JUnit for a Simple Test © 2010 John Wiley & Sons Ltd. 22

Red Output of JUnit for a Simple Test © 2010 John Wiley & Sons Ltd. 23

Partitioning adjustQuality() Out of Range © 2010 John Wiley & Sons Ltd.