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:

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
The Line Class Suppose you are involved in the development of a large mathematical application, and this application needs an object to represent a Line.
White Box and Black Box Testing Tor Stålhane. What is White Box testing White box testing is testing where we use the info available from the code of.
Introduction to C# Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Functions ROBERT REAVES. Functions  Interface – the formal description of what a subprogram does and how we communicate with it  Encapsulation – Hiding.
Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007.
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
Methods Liang, Chapter 4. What is a method? A method is a way of running an ‘encapsulated’ series of commands. System.out.println(“ Whazzup ”); JOptionPane.showMessageDialog(null,
 To be able to write larger programs ◦ By breaking them down into smaller parts and passing data between the parts.  To understand the concepts of Methods.
BUILDING JAVA PROGRAMS CHAPTER 7 Array Algorithms.
Object Specification Moving towards a more precise specification of software.
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
Introduction to Programming G51PRG University of Nottingham Revision 2 Essam Eliwa.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Ranga Rodrigo. Class is central to object oriented programming.
System/Software Testing
Topics in Software Dynamic White-box Testing Part 2: Data-flow Testing
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
Introduction Ellen Walker CPSC 201 Data Structures Hiram College.
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 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.
1 Phase Testing. \ 2 Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine subphases) Define Coding Standards.
From Use Cases to Test Cases 1. A Tester’s Perspective  Without use cases testers will approach the system to be tested as a “black box”. “What, exactly,
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Object-Oriented Programming (OOP). Implementing an OOD in Java Each class is stored in a separate file. All files must be stored in the same package.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Neil Ghani Software testing. 2 Introduction In a perfect world all programs fully verified testing thus redundant Back in the real.
Two Parts of Every ADT An abstract data type (ADT)  is a type for encapsulating related data  is abstract in the sense that it hides distracting implementation.
Chapter 2: Java Fundamentals
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Methods (a.k.a. Functions)
Software Construction Lecture 18 Software Testing.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 7 Clicker Questions September 22, 2009.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Branches and Program Design
ArrayList Class An ArrayList is an object that contains a sequence of elements that are ordered by position. An ArrayList is an object that contains a.
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
Java Arrays and Methods MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
1 Building Java Programs Chapter 3: Introduction to Parameters and Objects These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Select (drop-down list) Inputs. Insert/Form/List Menu.
Phase Testing: More examples 1. Review: Selecting Glass box test cases  Determine what to test (select types of coverage)  Create a flowchart for code.
Chapter 8: Designing Classes Accessors, Mutators, and Immutable Classes(8.3) Side Effects(8.4) Parameter Passing (Advanced Topic 8.1) Preconditions and.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Control Flow Graphs : The if Statement 1 if (x < y) { y = 0; x = x + 1; } else { x = y; } x >= yx < y x = y y = 0 x = x + 1 if (x < y) { y = 0;
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
COP 2220 Computer Science I Topics –Breaking Problems Down –Functions –User-defined Functions –Calling Functions –Variable Scope Lecture 4.
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
CS305j Introduction to Computing Parameters and Methods 1 Topic 8 Parameters and Methods "We're flooding people with information. We need to feed it through.
CPSC 252 ADTs and C++ Classes Page 1 Abstract data types (ADTs) An abstract data type is a user-defined data type that has: private data hidden inside.
Throw, Throws & Try-Catch Statements Explanations and Pictures from: Reference:
Section 3.3 Exceptional Situations. 3.3 Exceptional Situations Exceptional situation Associated with an unusual, sometimes unpredictable event, detectable.
Software Testing. SE, Testing, Hans van Vliet, © Nasty question  Suppose you are being asked to lead the team to test the software that controls.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Dynamic Black-Box Testing Part 1 What is dynamic black-box testing? How to reduce the number of test cases using: Equivalence partitioning Boundary value.
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
COURSE OUTLINE INTRODUCTION DATA TYPES AND LIBRARIES
SELECTION STATEMENTS (1)
Week 4 Lecture-2 Chapter 6 (Methods).
CSE 1020:Software Development
Presentation transcript:

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: – White-box Testing – Black-box Testing

White-box Testing White-box Testing: – We know the implementation details (how) – Tests the method based on covering all code branches (paths) – Branch – A code segment that is not always executed if-else statement switch statement while Why we avoid break and continue statements – Path – combination of branches that might be traversed when a program is executed Create test cases that test the various branches or paths. For large software projects, achieving 100% path coverage is often not a feasible goal.

Black-box Testing Black-box Testing: – We know the specification of the method (what) – Given an input we know what the output should be. Thus, treating the method as a “black box” – We do not know the implementation details (how) Impossible to test your program for every possible input value. First determine the possible input categories. E.g., – expected values – boundary values – out of range values – illegal values What should be your black box test plan if you prompt the user for an integer between 1 and 1000?

Preconditions and Postconditions A precondition is a statement of any assumptions or constraints on the input parameters before a method begins execution A postcondition describes the result of executing the method, including any change to the object’s state A method's preconditions and postconditions serve as a contract between a method caller and the method programmer /** Pre: this.grid must contain a cell in position [i][j] Post: returns a count of the number of neighbors of cell[i][j] that are infected. */ public int neighborsInfected(int i, int j){ … }

Unit Testing with Drivers A driver program – declares any necessary object instances and variables – assigns values to any of the method's inputs (specified by the preconditions) – calls the method – displays the outputs returned by the method Driver code is placed in a main method (usually in a separate class called TestingMyClass)

Test Driver ArrayList public static void main(String[] args) { // Create ArrayList ArrayList myList = new ArrayList(); myList.add("Barb"); myList.add("Mary"); myList.add("Liz"); myList.add("Barb"); myList.add("Mary"); // Test indexOf() method if (myList.indexOf(“Barb”) == 0) System.out.println ("SUCCESS – indexOf() first element"); else System.out.println ("FAILURE – indexOf() first element"); if (myList.indexOf(“Fred”) == -1) System.out.println ("SUCCESS – indexOf() element not in the list"); else System.out.println ("FAILURE – indexOf() element not in the list");