Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.

Slides:



Advertisements
Similar presentations
Debugging ACL Scripts.
Advertisements

Towards Self-Testing in Autonomic Computing Systems Tariq M. King, Djuradj Babich, Jonatan Alava, and Peter J. Clarke Software Testing Research Group Florida.
Software Quality Assurance Plan
Testing & Debugging CSC 171 FALL 2004 LECTURE 13.
1 Software Testing and Quality Assurance Lecture 30 - Introduction to Software Testing.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Understand.
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.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
Test Design Techniques
1 Shawlands Academy Higher Computing Software Development Unit.
TESTING.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Introduction Telerik Software Academy Software Quality Assurance.
Transaction Processing System
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
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.
Chapter 8 – Software Testing Lecture 1 1Chapter 8 Software testing The bearing of a child takes nine months, no matter how many women are assigned. Many.
Teaching material for a course in Software Project Management & Software Engineering – part II.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
Week 3 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Week 10 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
By Touseef Tahir Software Testing Basics. Today's Agenda Software Quality assurance Software Testing Software Test cases Software Test Plans Software.
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Week 12 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 10 - Testing.
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
CS Fall 2007 Dr. Barbara Boucher Owens. CS 2 Text –Main, Michael. Data Structures & Other Objects in Java Third Edition Objectives –Master building.
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.
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
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.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Software Development p Data structure p A collection of data organized so that the data can be accessed using a set of specific techniques p Object-oriented.
Software Testing and Quality Assurance Practical Considerations (4) 1.
The Software Development Process
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
Week 7 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
Intoduction to Unit Testing Using JUnit to structure Unit Testing SE-2030 Dr. Mark L. Hornick 1.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved.
(1) Test Driven Development Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
Software Quality Assurance and Testing Fazal Rehman Shamil.
Week 9 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Dynamic Testing.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Week 13 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
T EST T OOLS U NIT VI This unit contains the overview of the test tools. Also prerequisites for applying these tools, tools selection and implementation.
Testing JUnit Testing. Testing Testing can mean many different things It certainly includes running a completed program with various inputs It also includes.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
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.
SOFTWARE TESTING AND QUALITY ASSURANCE. Software Testing.
CS223: Software Engineering Lecture 25: Software Testing.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Applied Software Implementation & Testing
Testing and Test-Driven Development CSC 4700 Software Engineering
Chapter 1 Introduction(1.1)
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
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham

Week 13 Topics Unit Tests Providing Test Input Test Case Evaluation Regression Testing and Test Coverage Logging Using a Debugger

Unit Tests Unit tests are used to test classes in isolation of one another The Unit Testing framework we have been using in this course is JUnit A Unit Testing framework typically allows the programmer to compare a predetermined expected result against the result produced by the program

Unit Tests Cont. It is challenging to test a class in isolation if it depends on another class Testing classes in isolation when they have dependencies requires an advanced testing technique called mock objects Mock objects are objects that are designed specifically for the purpose of testing, but don’t actually implement the functionality of the class being mocked

Unit Tests Cont. A Mock class is stuffed with dummy data that the dependent class needs for its tests and keeps track of methods that the dependent class calls on itself The testing framework can then validate that the class interacted properly with the mock class Mock objects are so common that there are several frameworks for dynamically creating mock objects in Java

Unit Tests Cont. A class that is coded for the purpose of feeding parameters into methods that are being tested is called a test harness A test harness class is in essence a manual approach to doing unit testing A test harness should be repeatable, that is, data that has already been inputted should be documented

Unit Tests Cont. public void testGetRoot() // JUnit method { double x = RootApproximator r = new RootApproximator(x); assertEquals(10.0, r.getRoot(),.0001); }

Unit Tests Cont. public void class TestRootApproximator() {... // Test harness class, partial code in main double x = RootApproximator r = new RootApproximator(x); if (Math.abs( r.getRoot()) <=.0001) System.out.println(“Test case 1 passed”); }

Providing Test Input Crafting test input tests that are repeatable is an key component of program debugging and maintenance efforts Being able to repeat a test and validate that the outputs are still correct is important when coding changes are made to a program (regression testing) Typically, test data is stored in a file or database

Providing Test Input Cont. Positive test cases are test cases that are expected to pass Negative test cases are test cases that are expected to fail Boundary test cases are test cases that lay right on the boundary of acceptable inputs (0 would be an example if negative numbers not allowed)

Providing Test Input Cont. Special test cases are test cases that test situations such as values just to the positive or negative side of a boundary test case, or division by zero, etc. A table of test cases should be created prior to testing after doing an analysis of the problem domain; this activity is at least as important as program coding and should precede the coding task!

Test Case Evaluation How to determine if an output is correct is a key factor of a testing methodology Sometimes an expected output can be calculated by hand An expected value might be calculated via code that iterates many times to derive a value

Test Case Evaluation Cont. There may be a less efficient way to calculate a value than the approach that is being employed by the method being tested This slower but reliable method is called an oracle Thus, a test harness class can be written that compares the method output to the results of an oracle

Regression Testing and Test Coverage A test suite is a set of tests for repeated testing Regression testing involves repeating previously run tests to ensure that known failures of prior versions do not appear in new versions of the software White-box testing uses information about the structure of a program

Regression Testing and Test Coverage Cont. Black-box testing describes a testing method that does not take the structure of the implementation into account Test coverage is a measure of taking into account how many parts of a program have been tested For example, you should test every branch of all if/else code

Logging Logging is a way of tracing the execution of a program through all the method calls More than a useful debugging tool, logging can be a business requirement in many situations Consider that all bank transactions should be logged for accounting purposes

Logging Cont. However, the most common use for logging is debugging A logging API allows a programmer to log messages at various levels of severity, capture the log to a file, and even turn logging on and off entirely

Using a Debugger A debugger is a program that you can use to execute another program and analyze its run-time behavior You can make effective use of a debugger by mastering just three concepts: breakpoints, single-stepping, and inspecting variables

Using a Debugger Cont. When a debugger executes a program, the execution is suspended whenever a breakpoint is reached The single-step command executes the program one step at a time You should step into a method to check if carries out its job correctly, you should step over it if you know it works correctly

Reference: Big Java 2 nd Edition by Cay Horstmann Unit Tests (section 10.1 in Big Java) Providing Test Input (section 10.2 in Big Java) Test Case Evaluation (section 10.3 in Big Java) Regression Testing and Test Coverage (section 10.4 in Big Java) Logging (section 10.5 in Big Java) Using a Debugger (section 10.6 in Big Java)