CSIS 3701: Advanced Object Oriented Programming

Slides:



Advertisements
Similar presentations
Detecting Bugs Using Assertions Ben Scribner. Defining the Problem  Bugs exist  Unexpected errors happen Hardware failures Loss of data Data may exist.
Advertisements

The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
Lecture 27 Exceptions COMP1681 / SE15 Introduction to Programming.
CPSC150 Click to edit Master title style Click to edit Master text styles Second level Third level Fourth level Fifth level 1 CPSC150 Exceptions When things.
24-Jun-15 JUnit. 2 Test suites Obviously you have to test your code to get it working in the first place You can do ad hoc testing (running whatever tests.
Options for User Input Options for getting information from the user –Write event-driven code Con: requires a significant amount of new code to set-up.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Writing Classes (Chapter 4)
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
Static Class Methods CSIS 3701: Advanced Object Oriented Programming.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
Unit Testing CSIS 3701: Advanced Object Oriented Programming.
Exercise 2 Introduction to C# CIS Create a class called Employee that contains the following private instance variables: Social Securitystring.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
1 Unit Testing with JUnit CS 3331 JUnit website at Kent Beck and Eric Gamma. Test Infected: Programmers Love Writing Tests, Java Report,
Unit Testing Part 2: Drivers and Stubs
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
Unit Testing in Eclipse Presented by David Eisler 08/09/2014.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Java Visual Applications CSIS 3701: Advanced Object Oriented Programming.
Java 5 Class Anatomy. User Defined Classes To this point we’ve been using classes that have been defined in the Java standard class library. Creating.
Java Methods and Applications CSIS 3701: Advanced Object Oriented Programming.
Unit Testing.
Verification and Validation
Exceptions In this lecture:
Dept of Computer Science University of Maryland College Park
Object-Oriented Programming Using Java
Logger, Assert and Invariants
Introduction to JUnit CS 4501 / 6501 Software Testing
Inheritance and Encapsulation
USING ECLIPSE TO CREATE HELLO WORLD
Classes and Objects in Java
Computer Programming I
Computer Science 209 Testing With JUnit.
Exceptions The Need for Exceptions Throwing Exceptions
Creating and Modifying Text part 2
SwE 455 Program Slicing.
Software Engineering 1, CS 355 Unit Testing with JUnit
Important terms Black-box testing White-box testing Regression testing
PRG 420 NERD Lessons in Excellence -- prg420nerd.com.
PRG 420 NERD Education for Service-- prg420nerd.com.
Important terms Black-box testing White-box testing Regression testing
Writing Methods.
How to Run a Java Program
Chapter 12 Exception Handling and Text IO
COMPUTER 2430 Object Oriented Programming and Data Structures I
Interfaces and Constructors
Java IO and Testing made simple
Fundamental Error Handling
How to Run a Java Program
Testing, debugging, and using support libraries
Classes and Objects in Java
CLASSES, AND OBJECTS A FIRST LOOK
Barb Ericson Georgia Institute of Technology June 2005
CS 240 – Advanced Programming Concepts
Overview of Java 6-Apr-19.
Chapter 11 Inheritance and Polymorphism Part 1
CS-1020 and Exception Handling
Barb Ericson Georgia Institute of Technology Oct 2005
Lecture 14: Testing Testing used to verify object behavior through designed test suites Can test Classes – “unit” testing Object interactions – “integration”
LCC 6310 Computation as an Expressive Medium
Classes and Objects in Java
Loops CGS3416 Spring 2019 Lecture 7.
How to Run a Java Program
Presentation transcript:

CSIS 3701: Advanced Object Oriented Programming Regression Testing CSIS 3701: Advanced Object Oriented Programming

Class Drivers in Java public static void main(String[] args) { Example: Simple driver for add method in NameList public static void main(String[] args) { NameList n = new NameList(3); while(true) { String name = JOptionPane.showInputDialog(null, "Enter name"); n.add(name); JOptionPane.showMessageDialog(null, n.toString()); }

Class Drivers in Java public static void main(String[] args) { May need additional code for exceptions public static void main(String[] args) { NameList n = new NameList(3); while(true) { String name = JOptionPane.showInputDialog(null, “Name:"); try {n.add(name);} catch (FullListException ex) { JOptionPane.showMessageDialog(null, "List full!"); } catch (InListException ex) { JOptionPane.showMessageDialog(null, “In list!"); JOptionPane.showMessageDialog(null, n.toString());

Regression Testing Problem: Fixing bugs can introduce other errors 10% to 20% of bug fixes create new bugs Often happens as part of maintenance Developer who changes one module not familiar with rest of system Big problem: What if new bugs in code already tested? Module A tested first Fixing B creates bugs in A If A not retested, will be shipped with bugs! Module B tested second

Regression Testing Regression testing: Retesting with all test cases after any change to code Problem: May be thousands of tests! Too many for interactive debugging Comprehensive list of test cases Fix bugs Retest with all test cases Find bugs

Automated Testing Goal: Automate comprehensive testing Approaches: Run all test cases Notify developer of incorrect results Approaches: Creating testing “script” in driver Read test cases and desired results from file Use testing tools (JUnit)

Scripted Testing For each constructor/void method: Execute method Display value returned/exception thrown Get current state to desired state (using toString() ) Display current state Compare to desired state Error message if incorrect Display actual state

Scripted Testing Example public static void main(String[] args) { // Test default constructor Clock c1 = new Clock(); if (!(c1.toString()).equals("00:00")) System.out.println("Default constructor failure:" +c1.toString()); // Test parameterized constructor Clock c2 = new Clock(12,34); if (!(c2.toString()).equals("12:34")) System.out.println("Parameter constructor failure:" +c2.toString());

Scripted Testing Example // Test ability to set new time c2.setTime(9,1); if (!(c2.toString()).equals("09:01")) System.out.println("setTime failure: "+c2.toString()); // Test ability of nextMinute to increment minute, hour Clock c3 = new Clock(11, 59); c3.nextMinute(); if (!(c3.toString()).equals("12:00")) System.out.println("next failure: "+c3.toString()); Clock c4 = new Clock(23, 59); c4.nextMinute(); if (!(c4.toString()).equals("00:00")) System.out.println("next failure: "+c4.toString());

Scripted Testing for Inspectors For each method that returns a value: Execute method Compare actual return value to desired value Compare actual state to desired state Make sure state not changed for inspectors // Test getter inspectors, make sure state not changed if (c2.getHour() != 9) System.out.println("getHour failure: "+c2.getHour()); if (!(c2.toString()).equals("09:01")) System.out.println("getHour changed state: " +c2.toString());

Scripted testing for Validation For each validation inspector: Run test case to get value (true or false) Compare to desired value For each validation case in modifier: Run test case Make sure state not changed

Scripted Testing Example // Test validation inspectors for border cases if (c2.isHour(-1)) System.out.println("isHour failure: -1"); if (!c2.isHour(0)) System.out.println("isHour failure: 0"); if (c2.isHour(24)) System.out.println("isHour failure: 24"); if (!c2.isHour(23)) System.out.println("isHour failure: 23");

Scripted Testing Example // Test validation in modifiers for no state change c2.setTime(-1,12); if (!(c2.toString()).equals("09:01")) System.out.println("setTime validation failure: " +c2.toString()); c2.setTime(24,12); System.out.println("setTime validation failure: " +c2.toString());