1 Introduction to Testing CIS*2450 Advanced Programming Concepts Based on “The Practice of Programming” by Brian W. Kernighan and Rob Pike, 1999.

Slides:



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

Software Testing Technique. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves.
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.
Lecture 8: Testing, Verification and Validation
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.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Creator: ACSession No: 13 Slide No: 1Reviewer: SS CSE300Advanced Software EngineeringFebruary 2006 Testing - Techniques CSE300 Advanced Software Engineering.
Chapter 17 Software Testing Techniques
Illinois Institute of Technology
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
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.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Software Engineering Lecture 12 Software Testing Techniques 1.
BY RAJESWARI S SOFTWARE TESTING. INTRODUCTION Software testing is the process of testing the software product. Effective software testing will contribute.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
Chapter 13 & 14 Software Testing Strategies and Techniques
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
System/Software Testing
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
TESTING.
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
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.
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 -- Part II. Testing The role of testing is to: w Locate errors that can then be fixed to produce a more reliable product w Design tests that systematically.
Agenda Introduction Overview of White-box testing Basis path testing
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
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.
08120: Programming 2: SoftwareTesting and Debugging Dr Mike Brayshaw.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Software Quality Assurance and Testing Fazal Rehman Shamil.
 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.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
SOFTWARE TESTING. SOFTWARE Software is not the collection of programs but also all associated documentation and configuration data which is need to make.
Software Testing Testing is the process of exercising a program with the specific intent of finding errors prior to delivery to the end user.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
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.
Testing Integral part of the software development process.
Chapter 17 Software Testing Techniques
Software Testing.
Rekayasa Perangkat Lunak Part-13
Software Testing.
Software Testing Techniques
Topics Introduction to Repetition Structures
Software Testing An Introduction.
Chapter 8 – Software Testing
Chapter 18 Software Testing Strategies
Chapter 13 & 14 Software Testing Strategies and Techniques
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.
Software Testing “If you can’t test it, you can’t design it”
Software Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
08120: Programming 2: SoftwareTesting and Debugging
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Presentation transcript:

1 Introduction to Testing CIS*2450 Advanced Programming Concepts Based on “The Practice of Programming” by Brian W. Kernighan and Rob Pike, 1999.

2 Series on Testing 1.Defensive programming Detect problems as early as possible 2.Intro. to testing Classic testing methods for “finished” code 3.Debugging Fixing defects uncovered by testing

3 Introduction to Testing..testing can demonstrate the presence of bugs, but not their absence....Edsger Dijkstra Debugging and testing are not the same thing! Testing is a systematic attempt to break a program. –Correct, bug-free programs by construction are the goal but until that is possible (if ever!) we have testing.

4 Introduction to Testing It is not unusual for developers to spend 40% of the total project time on testing. –For life-critical software (e.g. flight control, reactor monitoring), testing can cost 3 to 5 times as much as all other activities combined. Since testing is basically destructive in nature, it requires that the tester discard preconceived notions of the correctness of the software to be tested.

5 Software Testing Fundamentals Testing objectives include –Testing is a process of executing a program with the intent of finding an error. –A good test case is one that has a high probability of finding an as yet undiscovered error. –A successful test is one that uncovers an as yet undiscovered error.

6 Software Testing Fundamentals Testing should systematically uncover different classes of errors in a minimum amount of time and with a minimum amount of effort. –A secondary benefit of testing is that it demonstrates that the software appears to be working as stated in the specification. –The data collected through testing can also provide an indication of the software's reliability and quality. But, testing cannot show the absence of defects -- it can only show that software defects are present.

7 The Nature of Software Defects Typographical errors are random. Logic errors and incorrect assumptions are inversely proportional to the probability that a program path will be executed. –General processing tends to be well understood while special case processing tends to be prone to errors. We often believe that a logical path is not likely to be executed when in fact, it may be executed on a regular basis. –Our unconscious assumptions about control flow and data lead to design errors that can only be detected by testing.

8 Classic Forms of Testing “Black box” testing –Consider only public interface of module or entire program –Apply inputs, examine outputs, compare to spec –Ideally done by independent testing group (not original programmer) “White box” testing –Involves looking at module’s source code, then targeting tests at the statements

9 White Box Testing White box testing is a test case design method that uses the control structure of the procedural design to derive test cases. Test cases can be derived that –guarantee that all independent paths within a module have been exercised at least once, –exercise all logical decisions on their true and false sides, –execute all loops at their boundaries and within their operational bounds, and –exercise internal data structures to ensure their validity.

10 Steps to Testing Nirvana Think about potential problems as you design and implement. Make a note of them and develop tests that will exercise these problem areas. –Document all loops and their boundary conditions, all arrays and their boundary conditions, all variables and their range of permissible values. –Pay special attention to parameters from the command line and into functions and what are their valid and invalid values. –Enumerate the possible combinations and situations for a piece of code and design tests for all of them. –GIGO - what happens when garbage goes in?

11 Steps to Testing Nirvana Test systematically, starting with easy tests and working up to more elaborate ones. –Often leads to “bottom up” testing, starting with simplest modules at the lowest level of calling –When those are working, test their callers –Document (and/or automate) this testing so that it can be repeated (regression testing) constantly as the code grows and changes.

12 Steps to Testing Nirvana Within a module, test incrementally as you code –Write, test, add more code, test again, repeat –The earlier that errors are detected, the easier they are to locate and fix.

13 Tricks of the Trade Test boundary conditions. –loops and conditional statements should be checked to ensure that loops are executed the correct number of times and that branching is correct –if code is going to fail, it usually fails at a boundary –check for off-by-one errors, empty input, empty output

14 When will this code fail? int i; char s[MAX]; for (i=0; (s[i] = getchar()) != '\n' && i < MAX-1; ++i); s[--i] = '\0';

15 Strategies Know what output to expect. –It is obvious that you cannot know if your program is correct unless you know what output it should produce in all situations. –As programs become bigger and more complicated, this becomes harder and harder to do. –Use programs like cmp (compare files for identity) and diff (report differences) to compare against known results.

16 Strategies Measure test coverage. –All lines in the code should be executed by one of your tests. –This is a very difficult thing to achieve or, indeed, to even know if you have achieved it! –Some profilers have a feature which provides a statement frequency count for all lines in the code. –The bottom lines is, “if you haven't tested it, you don't know if it has a bug in it!”

17 Scaffolding Software scaffolding is built for the purpose of making it easy to exercise code. It consists of temporary programs and data that give programmers access to system components. It is indispensable during testing and debugging but is usually never delivered to the customer. If an error is detected in the code, then its scaffolding can be reused.

18 An Isolation Technique Scaffolding also allows some module(s) to be tested without the risk of it being affected by interactions with other modules. Scaffolding is a particularly useful technique when it takes several minutes to execute each test case because the code being tested is embedded in other code. Scaffolding allows you to exercise code directly. Scaffolding is often big -- estimates range from half as much code in scaffolding as there is in the product to as much scaffolding as delivered code.

19 Types of Scaffolding: The Stub A stub is a low-level module that is really just dummy code so that it can be called by a higher- level module that is being tested. A stub can: –take no action and return control immediately, –test the data fed to it, –print a diagnostic message, perhaps just echoing the input parameters –return a standard answer regardless of the input, –provide timing -- burn up the number of clock cycles allocated to the real module, or –function as a quick and dirty version of the real module.

20 Types of Scaffolding: The Driver A driver is a fake module that calls the real module being tested. It is sometimes called a test harness. It can: –call the module to be tested with a fixed set of inputs, –prompt for input interactively, or take arguments from the command line, or read arguments from a file and call the module, or –run through predefined sets of input data in multiple calls to the module.

21 Types of Scaffolding: the Dummy File A dummy file is a small version of the real file that has the same types of components as that file. Advantages include: –its small size allows you to know its exact contents, and –more chance of it being error-free. –Since it is designed for testing, the contents can be designed to make any error conspicuous.

22 Scaffolding Construction Write one or more modules (to be tested) and separately compile them. –Even if the modules are not meant to stand by themselves. Write a main() scaffolding module and include calls to the other modules. –The main() module reads arguments from the command line (interactive program, file) and passes them to the modules being tested. –This exercises the modules on their own before integrating them with the rest of the system.

23 Scaffolding Construction After the tested module is integrated, save the scaffolding code –This code can even be left in the actual code and preprocessor commands or comments can be used to deactivate it during the actual operation of the system. –If you need to use it again, time is saved in recovering the test framework since you know where it is.

24 On to Debugging! Testing exposes defects in the software Still have to fix them = debugging –Doesn’t have to be hit-or-miss, can have strategies –Good news: Your debugging speed goes up as your experience grows → builds intuition that homes in on bugs more quickly