Testing & Debugging CSC 171 FALL 2004 LECTURE 13.

Slides:



Advertisements
Similar presentations
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
Advertisements

Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
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.
Chapter 1. The Phases of Software Development. Data Structure 2 Chapter outline  Objectives  Use Javadoc to write a method’s complete specification.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
Patriot Missile Failure
Classes, methods, and conditional statements We’re past the basics. These are the roots.
OOP #10: Correctness Fritz Henglein. Wrap-up: Types A type is a collection of objects with common behavior (operations and properties). (Abstract) types.
Chapter 8 Testing and Debugging Goals To learn how to carry out unit tests To understand the principles of test case selection and evaluation To learn.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
CS1101: Programming Methodology Aaron Tan.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
System/Software 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 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
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.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Introduction to Software Testing
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 10 - Testing.
Chapter 10 – Testing and Debugging. Chapter Goals ► Learn techniques to test your code ► Learn to carry out unit tests ► Understand principles of test.
Fall 2006Adapted from Java Concepts Companion Slides1 Testing and Debugging Advanced Programming ICOM 4015 Lecture 9 Reading: Java Concepts Chapter 10.
10/16/20151 Sources of Error Major: All Engineering Majors Authors: Autar Kaw, Luke Snyder Transforming Numerical Methods.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 8: Testing and Debugging 1 Chapter 8 Testing and Debugging.
Google C++ Testing Framework Death Tests. In many applications, there are assertions that can cause application failure if a condition is not met. ◦ Square.
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.
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.
Chapter 10 Testing and Debugging. Chapter Goals ► To learn how to carry out unit tests ► To understand the principles of test case selection and evaluation.
16 October Reminder Types of Testing: Purpose  Functional testing  Usability testing  Conformance testing  Performance testing  Acceptance.
Lecture 08 – Documentation, debugging.  docstring  A special kind of string (text) used to provide documentation  Appears at the top of a module 
CSC 395 – Software Engineering Lecture 10: Execution-based Testing –or– We can make it better than it was. Better...faster...agiler.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Introduction to JUnit 3.8 SEG 3203 Winter ‘07 Prepared By Samia Niamatullah.
QA and Testing. QA Activity Processes monitoring Standards compliance monitoring Software testing Infrastructure testing Documentation testing Usability.
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.
Programming with Assertions © Allan C. Milne v
ITI 1120 Lab #5 Contributors: S. Boyd, R. Plesa, A. Felty, D. Inkpen, A. Williams, D. Amyot.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Mutation Testing G. Rothermel. Fault-Based Testing White-box and black-box testing techniques use coverage of code or requirements as a “proxy” for designing.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
Week 7 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
1 Chapter 8: Testing and Debugging  Chapter Goals To learn how to design test harnesses for testing components of your programs in isolationTo learn how.
Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.
Mutation Testing Breaking the application to test it.
Testing JUnit Testing. Testing Testing can mean many different things It certainly includes running a completed program with various inputs It also includes.
Random Test Generation of Unit Tests: Randoop Experience
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Bugs CS100 how to prevent them, how to find them and how to terminate them.
Chapter 10 – Testing and Debugging. Goals Learn techniques to test your code Learn techniques to test your code Learn to carry out unit tests Learn to.
CS223: Software Engineering Lecture 25: Software Testing.
Test Case Purification for Improving Fault Localization presented by Taehoon Kwak SoftWare Testing & Verification Group Jifeng Xuan, Martin Monperrus [FSE’14]
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Testing Tutorial 7.
Programming in Java Assertion.
Sources of Error Major: All Engineering Majors
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Sources of Error Major: All Engineering Majors
Whitebox Testing.
CSE 1020:Software Development
Sources of Error Major: All Engineering Majors
Lecture 14: Testing Testing used to verify object behavior through designed test suites Can test Classes – “unit” testing Object interactions – “integration”
Sources of Error Major: All Engineering Majors
Defensive Programming
Presentation transcript:

Testing & Debugging CSC 171 FALL 2004 LECTURE 13

Reading Read Chapter 8 of Horstmann We will be doing this in labs

BUGS?

TERMINOLOGY Using the term “fault” instead of “bug” is one step toward professionalism

Therac-25

PATRIOT MISSILE On February 25, 1991, a Patriot missile defense system operating at Dhahran, Saudi Arabia, during Operation Desert Storm failed to track and intercept an incoming Scud. This Scud subsequently hit an Army barracks, killing 28 Americans. The Patriot battery at Dhahran failed to track and intercept the Scud missile because of a software problem in the system's weapons control computer.

UNIT TESTING Test classes in isolation, outside the program in which they are used Test one class at a time Supply test inputs through test harness Test harness = program that feeds test inputs to a class

public static double power(int a, int n) { int r = 1; int b = a; int i = n ; while (i>0) { if (i%2 == 0) { b = b * b; i = i / 2;} else { r = r * b; i--; } } return r; }

Sources of Test Data Provided by humans Computer-generated sequence Random sequence

Test Cases Positive test case: expect positive outcome E.g square root of 100 Negative test case: expect negative outcome E.g square root of 100 Boundary test case: at boundary of domain Frequent cause for errors E.g square root of 0

Test Case Evaluation Manual Check property of result E.g. square root squared = original value Oracle = slower way of computing answer E.g. square root of x = x1/2

Regression Testing Save test cases Automate testing java Program test1.out java Program test2.out java Program test3.out Repeat test whenever program changes Test suite = collection of test cases Cycling = bug that is fixed but reappears in later versions Regression testing = testing against past failures

Test Coverage Black-box testing: test functionality without understanding internal structure White-box testing: take internal structure into account when designing tests Test coverage: the code that is actually executed during test cases Easy to overlook error branches during testing Make sure to execute each branch in at least one test case

Program Trace Output statements in your program for diagnostic purposes if (status == SINGLE) { System.out.println("status is SINGLE");... }

Stack Trace Stack trace tells you the contents of the call stack Throwable t = new Throwable(); t.printStackTrace(System.out); Looks like exception report: java.lang.Throwable at TaxReturn.getTax(TaxReturn.java:26) at TaxReturnTest.main(TaxReturnTest.java:30) Drawback of trace messages: Need to remove them when testing is complete, stick them back in when another error is found

Logging Get global logger object: Logger logger = Logger.getLogger("global"); Log a message logger.info("status is SINGLE"); By default, logged messages are printed. Turn them off with logger.setLevel(Level.OFF);

Assertions Assertion = assumption that you believe to be true assert y >= 0; root = Math.sqrt(y); If assertion fails, program is terminated Can be used to assert pre/postconditions Must compile/run with special flags javac -source 1.4 MyProg.java java -enableassertions MyProg