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.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Testing and Quality Assurance
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.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Well-behaved objects 4.0 Testing. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to.
Introduction to Eclipse, Unit Testing and JUnit David Rabinowitz.
Exam Review 2 Chapter 5 – 9 CS211 November 05,2007, CS Dept, MHC.
OOP #10: Correctness Fritz Henglein. Wrap-up: Types A type is a collection of objects with common behavior (operations and properties). (Abstract) types.
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.
Copyright by Scott GrissomCh 1 Software Development Slide 1 Software Development The process of developing large software projects Different Approaches.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
Chapter 11: Testing The dynamic verification of the behavior of a program on a finite set of test cases, suitable selected from the usually infinite execution.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Test Driven Development TDD. Testing ”Testing can never demonstrate the absence of errors in software, only their presence” Edsger W. Dijkstra (but it.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
1 Shawlands Academy Higher Computing Software Development Unit.
Introduction to Unit Testing Jun-Ru Chang 2012/05/03.
TESTING.
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.
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.
COMP 121 Week 7: Object-Oriented Design and Efficiency of Algorithms.
Software Testing Damian Gordon.
Lecture 11 Testing and Debugging SFDV Principles of Information Systems.
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 10 - Testing.
Design and Programming Chapter 7 Applied Software Project Management, Stellman & Greene See also:
Software Testing The process of operating a system or component under specified conditions, observing and recording the results, and making an evaluation.
Chapter 10 – Testing and Debugging. Chapter Goals ► Learn techniques to test your code ► Learn to carry out unit tests ► Understand principles of test.
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.
DEBUGGING. BUG A software bug is an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
The Software Development Process
Debuggers in Python. The Debugger Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
OOPDA Intro 5.0. Topics Website and Syllabus Rowan VPN and H:drive BlueJ application and projects Programming Style (Appendix J) Javadoc (Appendix I)
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.
Software Quality Assurance and Testing Fazal Rehman Shamil.
Testing Data Structures Tao Xie Visiting Professor, Peking University Associate Professor, North Carolina State University
Dynamic Testing.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Testing and Debugging. Testing Fundamentals  Test as you develop Easier to find bugs early rather than later Prototyping helps identify problems early.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Unit Testing with FlexUnit
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
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.
Cs498dm Software Testing Darko Marinov January 24, 2012.
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.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
MOOR ERROR HANDLING Types of error How to test your code for errors How to detect errors How to recover from errors.
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Implementation Topics Describe –Characteristics of good implementations –Best practices to achieve them Understand role of comments Learn debugging techniques.
Testing Tutorial 7.
Some Simple Definitions for Testing
Testing UW CSE 160 Spring 2018.
Design and Programming
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
CSE 1020:Software Development
Chapter 9: Implementation
Testing Slides adopted from John Jannotti, Brown University
Presentation transcript:

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 Dijkstra, E. W. (1970). Notes on structured programming. Retrieved September 4, 2007, from

Testing is an Important Skill Microsoft … we have as many testers as we have developers. And testers spend all their time testing, and developers spend half their time testing. We're more of a testing, a quality software organization than we're a software organization. ~ Bill Gates Foley, J. & Murphy, C. (2002). Q&A: Bill Gates on trustworthy computing. InformationWeek. Retrieved September 4, 2007, from

Why Write Test Cases? Tests reduce bugs in new features Tests reduce bugs in existing features Tests are good documentation Tests reduce the cost of change Tests improve design Tests allow refactoring Tests constrain features Tests defend against other programmers Testing is fun Testing forces you to slow down and think Testing makes development faster Tests reduce fear Burke, E.M. & Coyner, B.M. (2003). Top 12 reasons to write unit tests. Retrieved September 1, 2007, from

What is a Test Case? Informal definition -- a test case is a piece of code that programmatically checks that another piece of code works correctly Each test case is a method that usually tests another method (often called the “method under test”)

Some Types of Test Cases Positive test cases test that the method under test works correctly with expected, legitimate inputs  “happy path”  Test for success Boundary test cases test how the method under test handles values that lie at the boundary of acceptable inputs  Legal values that often cause problems in code zero, empty strings, null object references Negative test cases try to show that the method under test does not work or that the method under test handles error conditions Open-ended Test for failure Horstmann, C. (2008). Big Java (3 rd ed.). New York: John Wiley & Sons.

Black-box vs. White-box Testing Black-box testing describes a testing method that does not take the structure of the implementation into account  Based on what is externally visible (inputs and expected outputs) White-box testing uses information about the structure of a program  Based on implementation details Horstmann, C. (2008). Big Java (3 rd ed.). New York: John Wiley & Sons.

Regression Testing and Test Coverage Regression testing  Repeating previously run tests to ensure that known failures of prior versions do not appear in the new versions of the software Test coverage  Every line of executable code should be executed at least once by test cases Every if / else branch All paths through your code Horstmann, C. (2008). Big Java (3 rd ed.). New York: John Wiley & Sons.

Question: How many test cases do you need to cover all branches of the getDescription method shown below? What are the boundaries? public String getDescription() { String r; if (richter >= 8.0) r = “Most structures fall”; else if (richter >= 7.0) r = “Many buildings destroyed”; else if (richter >= 6.0) r = “Many buildings considerably damaged, some collapse”; else if (richter >= 4.5) r = “Damage to poorly constructed buildings”; else if (richter >= 3.5) r = “Felt by many people, no destruction”; else if (richter >= 0) r = “Generally not felt by people”; else r = “Negative numbers are not valid”; return r; } private double richter; Horstmann, C. (2008). Big Java (3 rd ed.). New York: John Wiley & Sons.

Test-Driven Development

Testing in BlueJ BlueJ allows for ad hoc and systematic unit testing  Ad hoc testing allows you to test a method interactively  Systematic testing is done using the JUnit regression testing framework  BlueJ can be used to generate test cases or to build test cases by hand When you installed BlueJ, it should have included a tutorial on testing which also can be downloaded from:

Debugging Informal definition -- debugging is the process of finding and fixing problems (bugs) in a computer program or in computer hardware

The First Bug Department of the Navy. (2006). Online library of selected images: Rear Admiral Grace Murray Hopper, USNR, ( ). Retrieved September 4, 2007, from

Steps to Debug a Program Reproduce the error Simplify the error Divide and conquer Know what your program should do Look at all details Make sure you understand each bug before you fix it Horstmann, C. (2008). Big Java (3 rd ed.). New York: John Wiley & Sons.

Debugger A debugger is a program that you can use to execute another program and analyze its run-time behavior Basic debugger functions:  Setting breakpoints  Stepping through code  Inspecting variables Horstmann, C. (2008). Big Java (3 rd ed.). New York: John Wiley & Sons.

Debugging in BlueJ A simple debugger is included in the BlueJ development environment Learning to use it can save you lots of time When you installed BlueJ, it should have included a tutorial which also can be downloaded from:  Debugger demonstration is on pages 27-30

Debugging Videos An ITiCSE working group created a repository of debugging video tutorials that demonstrate some debugging techniques, including how to use the BlueJ debugger

Summary Testing is an important part of software development Test cases can be used to develop code, find bugs, and make sure changes don’t break old code Test cases should provide full coverage, test the inputs and expected outputs, test boundaries, etc. JUnit is a framework used to develop test cases BlueJ supports JUnit test cases and also includes a debugger to help fix problems found in code

Any Questions?