Neil Ghani Software testing. 2 Introduction In a perfect world all programs fully verified testing thus redundant Back in the real.

Slides:



Advertisements
Similar presentations
Testing Relational Database
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.
Test process essentials Riitta Viitamäki,
Testing and Quality Assurance
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.
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.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
CS4723 Software Validation and Quality Assurance Lecture 02 Overview of Software Testing.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
Outline Types of errors Component Testing Testing Strategy
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
1 Joe Meehean. 2 Testing is the process of executing a program with the intent of finding errors. -Glenford Myers.
CSE 403 Lecture 13 Black/White-Box Testing Reading: Software Testing: Principles and Practices, Ch. 3-4 (Desikan, Ramesh) slides created by Marty Stepp.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
System/Software Testing
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
Introduction Telerik Software Academy Software Quality Assurance.
CMSC 345 Fall 2000 Unit Testing. The testing process.
Software Testing.
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.
1 Software testing. 2 Testing Objectives Testing is a process of executing a program with the intent of finding an error. A good test case is in that.
Testing E001 Access to Computing: Programming. 2 Introduction This presentation is designed to show you the importance of testing, and how it is used.
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
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.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
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.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
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.
CSC 1010 Programming for All Lecture 4 Loops Some material based on material from Marty Stepp, Instructor, University of Washington.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
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.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
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.
Testing Integral part of the software development process.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
Software Testing.
Chapter 9, Testing.
CS5123 Software Validation and Quality Assurance
Some Simple Definitions for Testing
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Chapter 14 Software Testing Techniques
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.
Chapter 11, Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

Neil Ghani Software testing

2 Introduction In a perfect world all programs fully verified testing thus redundant Back in the real world We are human so Make mistakes Can’t be bothered doing it properly Code for speed not accuracy So in this lecture we look at testing But not evaluation

3 Testing and evaluation Evaluation Qualitative decisions Is it a good system? HCI, purpose of system, use of resources, design You will be asked to (briefly) evaluate your system Testing Correctness decisions Does the system correctly perform its function Sins of omission – doesn’t do something it should Sins of commission – does do something it shouldn’t

4 Limits of software testing “ Testing is the process of executing a program with the intent of finding errors.” Glenn Myers “Good” testing will find bugs i.e. the program not doing what it should testing can prove the presence of bugs never their absence worst person to test code is the developer gives easy tests to avoid breaking it best person to test your code is someone else they will break it

5 Testing Is never complete (1) Module A takes integer input possible inputs If we test each possible input at one input millisecond, it would take 49 days to test this module So we need to choose good tests! Is never complete (2) We cannot replicate all situations in which software will be used We cannot predict everything a user will do with it Is never given enough time Testing is not proving code correct It is finding faults and fixing them (and then retesting) This takes time

6 Dynamic testing Static Analysis Hand execution: Reading the source code Walk-Through (informal presentation to others) Code Inspection (formal presentation to others) Automated Tools checking for Syntactic and semantic errors, e.g. compilers Dynamic Analysis Black-box testing (Test the specification) White-box testing (Test the code)

7 Black-box Testing Focus: I/O behavior. If for any given input, we can predict the output, then the module passes the test. Almost always impossible to generate all possible inputs ("test cases") Reduce number of test cases by equivalence partitioning Think about what input each module takes Divide input into equivalence classes i.e partition possible input data into sets of data Usually valid and invalid Choose one test cases for each equivalence class If module works for this input, works for all inputs of this class

8 Examples Method accepts one positive integer Two equivalence classes – valid and invalid Valid set – all positive integers Invalid set – all negative integers Test cases – 5 (valid), -1 (invalid) Method accepts one integer in range equivalence classes Valid data – any number between Invalid – too low – any number less than 1 Invalid – too high – any number greater than 10 Test cases – 5 (valid), 0 (invalid too low), 12 (invalid too high)

9 Examples Module takes a legitimate string i.e. no punctuation, spaces or digits Valid class Legitimate strings, e.g. ‘ian’, ‘programming’, ‘project’ Invalid classes ‘ian,’ – punctuation after ‘,ian’ – punctuation before ‘ian’s’ – punctuation in the middle ‘ian5s’ – digits anywhere ‘’ – empty string (valid?) For each input we need to think about what input is valid and what is not (and why) Also need invalid to check error-handling

10 Black box testing (contd) We also have to consider output E.g. module G takes a person’s age and returns Yes if the person is old enough to buy alcohol No, if the person is not old enough to buy alcohol Valid data are numbers greater than equal to 0 Invalid data are numbers less than 0 But some valid data will return yes, other no We need to test both Equivalence classes Valid + old enough – greater than or equal to 18 Valid + not old enough – Invalid – less than 0 018

11 Testing Questions for each variable What groups of data are valid What groups of data are invalid For each class, do we expect module to treat some data differently i.e. to give different outputs If yes, split class into sub-classes For some languages also need to treat different types of data as invalid e.g. input is one integer Invalid might also include strings, lists, etc

12 Examples Note: duplication tells us nothing! e.g. module takes a legitimate string valid class legitimate strings, e.g. ‘ian’, ‘programming’, ‘project’ testing ‘ian’ and ‘notian’ tells us nothing also worth testing boundary values e.g. module takes a integer in range of many errors happen at boundaries test 1, 10, 11, 0

13 Examples Can combine testing in some cases module A removes punctuation and digits from strings input – ‘st7in,d,s!?<>ss;’ expected output – ‘stindsss’ test is removal of all non-characters But not all test remove punctuation and enter word into bst No! unless you have already tested them separately

14 Test oracle We use test cases to specify a test oracle Set of test cases, each specifying input and predicted output for each equivalence class E.g. inputpredicted output 5 -1 error Predicted output used to test actual output Also need to do for combinations of input e.g. input5 (valid)5 (valid) -1 (invalid) 5 (valid) 5 (valid) -1 (invalid) -1 (invalid) –1 (invalid)

15 For your report Structure of test case Aim: “This test case tests the ability of the module to …… It assumes that input can only be integers because…” Input: the data used Predicted output: what you expect to happen if the module works correctly Actual output: What you actually got (the result) Conclusion: Did it work? If not why not and what (if anything) did you do to correct it? What does this tell us about the module?

16 Example Structure of test case Aim: “This test case tests the ability of the module to remove punctuation from a string. Assumes punctuation characters are all non-alphanumeric characters” Input: “”!ia?n%” Predicted output: “ian” Actual output: (1) “ian” (2) “ia” Conclusion: (1) The module correctly removes punctuation from the input string” Or (2) “The input string was printed out but the final letter was missing. The error was fixed by correcting the while loop and re-tested as test case X”

17 “Adequate” set of test cases Test the interface of the components all public methods Is one test case per method enough? Usually no! So, how many do we need? Depends on method More complex methods need more testing Methods that take more input need more testing But avoid duplication….. Testing the same thing twice tells us nothing

18 Automating software testing Manual software testing is time consuming Software testing has to be repeated after every change (regression testing) Write test drivers that can run automatically and produce a test report public boolean myTest() { int value1; int value2; int actual_result, expected_result; value1 = 5; value2 = 5; expected_result = 10; actual_result = Integer sum(value1, value2); return ( actual_result == expected_result ); }

19 Black box testing Tells us what happens outside module Tells us nothing about what goes on inside Module input output

20 White box testing our goal is to ensure that all statements and conditions have been executed at least once... Tests the code itself loop < 20x

21 White-box Testing Four types of white-box testing (1) Statement Testing Test single statements (assignments, etc) SumOfScores = 0.0; System.out.println(SumOfScores);

22 Loop Testing while (x > 0){ out.write(x); read(x);} Cause execution of the loop to be skipped completely. Set x to minus 1 Exception: For loops Loop to be executed exactly once Enter –1 as x Loop to be executed more than once Try different positive values of x Loop to be executed n times (n-1), n, and (n+1) passes through the loop White-box Testing (Continued)

23 White box testing Branch Testing (Conditional Testing) Make sure that each possible outcome from a condition is tested at least once Here, two test cases i=true, i=false if(i == ‘true’) System.out.println(‘True’); else if (i == ‘false’) System.out.println(‘False); And every condition is covered if(i < 0) System.out.println(‘True’); else if (i >0) System.out.println(‘False); What about i == 0???

24 Branch testing Path testing Test all ways (paths) an input can go through the program Define test cases that test each decision

25 Good design makes it easier Features that help/influence testing: observability the results are easy to see, simple data returned best distinct output is generated for each input incorrect output is easily identified decomposability software modules can be tested independently good cohesion! simplicity - no complex architecture and logic stability Fixing the design before you start coding! understandability program is easy to understand no kludges!

26 Testing vs. fault tolerance design and implementation Testing happens before software is released Finding errors and fixing them What about after release? Hardware faults, data transmission faults, poor user input, …. Fault tolerant design Assume that errors occur during execution and try to recover from them (also during execution) For complex and important systems we need both!

27 For this course Black-box testing is necessary White-box testing Similar documentation to before Is not necessary But will gain extra marks Also interface testing Need test cases Usually based on use cases Can people use it?