CMSC 132: OBJECT-ORIENTED PROGRAMMING II

Similar documents
CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 15 Testing

Computer Science and Software Engineering University of Wisconsin - Platteville 9-Software Testing, Verification and Validation

Chapter 11, Testing. Using UML, Patterns, and Java. Object-Oriented Software Engineering

Software Design Models, Tools & Processes. Lecture 6: Transition Phase Cecilia Mascolo

Overview. State-of-the-Art. Relative cost of error correction. CS 619 Introduction to OO Design and Development. Testing.

In this Lecture you will Learn: Testing in Software Development Process. What is Software Testing. Static Testing vs.

Test Driven Development TDD

Verification and Validation

Chapter 2.6: Testing and running a solution

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus

Lecture 10: Introduction to Correctness

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Testing. ECE/CS 5780/6780: Embedded System Design. Why is testing so hard? Why do testing?

Test suites Obviously you have to test your code to get it working in the first place You can do ad hoc testing (testing whatever occurs to you at

Testing & Debugging TB-1

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

Program Correctness and Efficiency. Chapter 2

Topics in Software Testing

Software Engineering: Theory and Practice. Verification by Testing. Test Case Design. Tom Verhoeff

Terminology. There are many different types of errors and different ways how we can deal with them.

Verification and Validation

Verification and Validation

Testing. CMSC 433 Programming Language Technologies and Paradigms Spring A Real Testing Example. Example (Black Box)?

Why testing and analysis. Software Testing. A framework for software testing. Outline. Software Qualities. Dependability Properties

Darshan Institute of Engineering & Technology for Diploma Studies

UNIT-4 Black Box & White Box Testing

Lecture 15 Software Testing

Software Testing Interview Question and Answer

Software Testing TEST CASE SELECTION AND ADEQUECY TEST EXECUTION

UNIT-4 Black Box & White Box Testing

Software Engineering and Scientific Computing

Unit Testing with JUnit and CppUnit

(See related materials in textbook.) CSE 435: Software Engineering (slides adapted from Ghezzi et al & Stirewalt

No Source Code. EEC 521: Software Engineering. Specification-Based Testing. Advantages

Software Quality Assurance (SQA) Software Quality Assurance

Testing. UW CSE 160 Winter 2016

Testing Stragegies. Black Box Testing. Test case

Test automation / JUnit. Building automatically repeatable test suites

Test automation Test automation / JUnit

Software Testing. Minsoo Ryu. Hanyang University. Real-Time Computing and Communications Lab., Hanyang University

Chapter 9. Software Testing

Black Box Testing. EEC 521: Software Engineering. Specification-Based Testing. No Source Code. Software Testing

Software Development Methodologies

Examination Questions Time allowed: 1 hour 15 minutes

TITAN 5300 Software. Unit Test Guidelines. S. Darling, S. Harpster, R. Hite, K. Konecki, W. Martersteck, R. Stewart. Revision 2.0

Software Testing for Developer Development Testing. Duvan Luong, Ph.D. Operational Excellence Networks

Testing and Debugging

Main concepts to be covered. Testing and Debugging. Code snippet of the day. Results. Testing Debugging Test automation Writing for maintainability

Testing. Christopher Simpkins Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS / 13

(From Glenford Myers: The Art of Software Testing)

XVIII. Software Testing. Laurea Triennale in Informatica Corso di Ingegneria del Software I A.A. 2006/2007 Andrea Polini

Part 5. Verification and Validation

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6!

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Software Engineering (CSC 4350/6350) Rao Casturi

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science

Software Testing CS 408

Chapter 8 Software Testing. Chapter 8 Software testing

Reliable programming

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Tuesday, November 15. Testing

C07: Testing and JUnit

Text Input and Conditionals

Software Testing and Maintenance

Software Testing 2. OOD and Testability. White box vs Black box Testing. Software Testing 2 Semester 1, 2006

Verification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80

Quote by Bruce Sterling, from: A Software Testing Primer, Nick Jenkins

System development, design & implementation

Variables and Data Representation

Testing! Prof. Leon Osterweil! CS 520/620! Spring 2013!

By Matthew Noonan, Project Manager, Resource Group s Embedded Systems & Solutions

Question 1: What is a code walk-through, and how is it performed?

University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I

Chapter 9 Quality and Change Management

Write perfect C code to solve the three problems below.

Pearson Education 2007 Chapter 9 (RASD 3/e)

EECS 4313 Software Engineering Testing

CSSE2002/7023 The University of Queensland

Testing & Continuous Integration. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 20 03/19/2010

QUALITY ASSURANCE amron

Testing and Debugging

Lecture 20: SW Testing Presented by: Mohammad El-Ramly, PhD

PC204. Lecture 5 Programming Methodologies. Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Ingegneria del Software Corso di Laurea in Informatica per il Management

Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered.

Manuel Oriol, CHCRC-C, Software Testing ABB

Second assignment came out Monday evening. Find defects in Hnefetafl rules written by your classmates. Topic: Code Inspection and Testing

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 11/10/2015

EXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist:

Agile Software Development. Lecture 7: Software Testing


CS 1110, LAB 3: MODULES AND TESTING First Name: Last Name: NetID:

Software Testing Lecture 1. Justin Pearson

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Learning outcomes. Systems Engineering. Debugging Process. Debugging Process. Review

Software Testing. Overview

Software Engineering Fall 2014

Preventing and Finding Bugs in Parallel Programs

Automated Requirements-Based Testing

Lab Exercise Test First using JUnit

Transcription:

CMSC 132: OBJECT-ORIENTED PROGRAMMING II Program Testing Department of Computer Science University of Maryland, College Park

Debugging Is Harder Than Coding! Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it Brian W. Kernighan and P. J. Plauger, The Elements of Programming

Program Testing Empirical testing Test software with selected test cases More scalable than verification Test failures frequently indicate software errors Absence of failures doesn t prove software correct If code isn t exercised by any test, hard to have confidence in it Even if it has been formally verified

Kinds of Testing Automated testing The software is tested by a completely automatic process e.g., junit or submit server testing Can be expensive or difficult to construct, but fairly cheap to repeat Manual testing A person uses the software, perhaps guided by a script, and notes bugs Often easier to conduct than writing test cases, but very expensive to repeat

Test Size Small Unit test test individual components Medium Integration tests Test subsystems containing several components Can test interactions between components, properties that are only demonstrated in larger systems Large System or acceptance tests Test entire system, including non-software components

Types of Testing Clear box testing Allowed to examine code Attempt to improve thoroughness of tests Black box testing No knowledge of code Treat program as black box Test behavior in response to inputs

Testing Terminology Test case Individual test Test suite Collection of test cases Test harness Program that executes a series of test cases Test framework Software that facilitates writing & running tests Example JUnit

Testing Terminology Test driver Stub Program to create environment for running tests Declares variables, creates objects, assigns values Invokes tested code, checks results, reports failures Skeleton code in place of unfinished method / class Implements minimal functionality to allow test to occur Allows software testing to begin

Mock Objects Similar to a stub But they record the calls made to them If the wrong calls are made to them, the test fails Can prerecord the sequence of expected calls Also eliminates need for mock objects to contain any logic Or the test driver can query the calls after the test Useful if calls aren t deterministic and need more careful logic to check

When to Use Mock Objects If you want to test the calls made to other objects, rather than the return values or output of the methods under test Mock objects can also be easier to use than creating functional stubs Mock objects can simulate situations that might be hard to test on real code e.g., Does the code recover if the network fails?

EasyMock Example warehousecontrol = MockControl.createControl(Warehouse.class); warehousemock = (Warehouse) warehousecontrol.getmock(); Order order = new Order(TALISKER, 50); // setup record expected calls and return values warehousemock.hasinventory(talisker, 50); warehousecontrol.setreturnvalue(true); warehousemock.remove(talisker, 50); warehousecontrol.replay(); // put mock into replay mode // exercise execute code under test order.fill(warehousemock); // verify warehousecontrol.verify(); asserttrue(order.isfilled());

Unit Test Test individual units extensively Classes Methods Central part of Extreme Programming (XP) Extensive unit testing during development Pair programming Design unit tests along with specification Approach Test each method of class Test every possible flow path through method

Flow Path Unique execution sequence through program Example S1 while (B1) { if (B2) S2 else S3 } Flows S1 S1, S2 S1, S3 S1, S2, S2 S1, S2, S3 S1, S3, S2 S1, S3, S3

Test Coverage Not possible to test all flow paths Many paths by combining conditionals, switches Infinite number of paths for loops New paths caused by exceptions Test coverage Whether code is executed by some test case Alternative to flow path Ensure high % (if not all) of lines of code tested Does not capture all possible flow paths Even if all lines of code tested by some test case

Test Coverage, Continued Branch coverage is stronger than statement coverage Generally achievable Can be tricky to cover all exceptions and error cases Control flow coverage doesn t tell you about data coverage Did you try it with negative integers, or with non-ascii characters? Coverage won t tell you about functionality you forgot to implement or test

When to Test If code has never been tested, you have no idea if it ever worked But it is also important to perform regression testing Check to see if some functionality that used to work stops working The faster a regression is identified, the cheaper it is to fix, at any scale Within a minute is better than within an hour Within a day is better than within a week

Why Regression Test? Running regression tests give developer much more freedom to change existing code I need to rewrite this component to support new functionality I wonder if anything might be depending on the details of how it works now? This freedom is key to agile development, and important even in more structured development methodologies

Selecting Regression Tests Big, well tested systems will have too many tests to run all of them every time you compile Prioritize tests by size Ones that take only a few seconds Ones that need to run over the weekend And by proximity to code changed After changing some code, you only need to rerun the tests that executed the code that was changed Research work on prioritizing tests

Developing Quality Test Cases Useful to have someone else write test cases One person might make the same incorrect assumption in both their code and in their tests Tips on developing test cases Develop test data during analysis & design phases Use cases Test cases Pay close attention to problem specification Check boundary conditions 1 st and last iterations of loop 1 st and last values added to data structure Improve code coverage

Miscellaneous Bug Tracking Dilbert Comic http://dilbert.com/strips/comic/1995-11-13/ Computer Bug http://www.history.navy.mil/photos/images/h96000/h96566kc.htm Tools for managing, tracking, performing statistics on bugs and vulnerabilities essential, particularly on large projects Bugzilla http://www.bugzilla.org/ Jira http://www.atlassian.com/software/jira/overview Javadoc Great tool to generate documentation Submit Server Uses clover for code coverage Runs findbugs on all java programs http://findbugs.sourceforge.net/