CS18000: Programming I

Similar documents
CS159. Nathan Sprague. September 30, 2015

Agile Software Development. Lecture 7: Software Testing

CS201 - Assignment 3, Part 1 Due: Friday February 28, at the beginning of class

Computer Science 62 Lab 8

Test automation / JUnit. Building automatically repeatable test suites

Test automation Test automation / JUnit

EECS 4313 Software Engineering Testing

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

Source Control. Comp-206 : Introduction to Software Systems Lecture 21. Alexandre Denault Computer Science McGill University Fall 2006

linaye/gl.html

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

CSCI 2600: Principles of Software. Spring 2017 Lecture 01 Bill Thompson

Software Development Tools. COMP220/COMP285 Sebastian Coope Eclipse and JUnit: Creating and running a JUnit test case

Assertions, pre/postconditions

Branches in Subversion, Debugging, scmbug

Unit testing. JUnit. JUnit and Eclipse. A JUnit test class 3/6/17. A method is flagged as a JUnit test case.

CS 211: Potpourri Enums, Packages, Unit Tests, Multi-dimensional Arrays Command Line Args

Introduction to JUnit

Video 2.1. Arvind Bhusnurmath. Property of Penn Engineering, Arvind Bhusnurmath. SD1x-2 1

Unit testing. unit testing: Looking for errors in a subsystem in isolation. The basic idea: JUnit provides "assert" commands to help us write tests.

JUnit Framework. Terminology: assertions, annotations, fixtures. Dr. Siobhán Drohan Mairead Meagher. Produced by:

Jtest Tutorial. Tutorial

Chapter 3. Revision Control

Test-Driven Development (a.k.a. Design to Test) CSE260, Computer Science B: Honors Stony Brook University

Thinking Functionally

Object Oriented Software Design - I

Version Control System. -- base on Subversion 1.4

CS18000: Programming I Final Exam 8 May 8am-10am Lilly Functional Abstraction. Functional Specification. CS18000: Programming I 4/28/2010

Unit Tests. Unit Testing. What to Do in Unit Testing? Who Does it? 4 tests (test types) You! as a programmer

CSE 374 Programming Concepts & Tools. Hal Perkins Winter 2012 Lecture 16 Version control and svn

SECTION 2: Loop Reasoning & HW3 Setup

SECTION 2: Loop Reasoning & HW3 Setup

CVS. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 21

Midterm Exam. CS169 Fall November 17, 2009 LOGIN: NAME: SID: Problem Max Points Points TOTAL 100

JUnit in EDA Introduction. 2 JUnit 4.3

Portions adapted from A Visual Guide to Version Control. Introduction to CVS

Improving Software Testability

INTRODUCTION TO JAVA PROGRAMMING JAVA FUNDAMENTALS PART 2

Subversion Repository Layout

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.

Version Control Systems: Overview

Testing on Steriods EECS /30

Test-Driven Development JUnit

Unit Testing as Hypothesis Testing

Testing. My favourite testing quote: Program testing can be used to show the presence of bugs, but never to show their absence!

Version Control Systems (Part 1)

Handout 4: Version Control Reference

Lab Exercise Test First using JUnit

A Short Introduction to Subversion

Software Testing part II (white box) Lecturer: Giuseppe Santucci

VSO. Configuration Management

Home Page. Title Page. Contents. Page 1 of 17. Version Control. Go Back. Ken Bloom. Full Screen. Linux User Group of Davis March 1, Close.

CSE 303, Autumn 2006, Final Examination 12 December 2006

KU Compilerbau - Programming Assignment

Test-Driven Development JUnit

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

Object-Oriented Design And Software Testing

Distributed Version Control

Getting It Right COMS W4115. Prof. Stephen A. Edwards Spring 2007 Columbia University Department of Computer Science

CSSE 220 Day 3. Check out UnitTesting and WordGames from SVN

And check out a copy of your group's source tree, where N is your one-digit group number and user is your rss username

12/7/09. How is a programming language processed? Picasso Design. Collaborating with Subversion Discussion of Preparation Analyses.

Module Road Map. 7. Version Control with Subversion Introduction Terminology

DD2460 Software Safety and Security: Part III Exercises session 2: Type + Jif

SECTION 2: HW3 Setup.

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

Revision Control. Software Engineering SS 2007

Tools for Unit Test - JUnit

377 Student Guide to C++

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control.

What is Subversion and what does it do?

Terminal Windows, Emacs, Subversion and Make

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

Introduction to Revision Control

CSCA08 Winter Week 12: Exceptions & Testing. Marzieh Ahmadzadeh, Brian Harrington University of Toronto Scarborough

Software Test. Levels of test. Types of test. Regression test The JUnit tool for unit testing Java programs. System test Integration test Unit test

Software Development. Hack, hack, hack, hack, hack. Sorta works. Main.c. COMP s1

System Software Assignment 1 Runtime Support for Procedures

All code must follow best practices. Part (but not all) of this is adhering to the following guidelines:

Testing. Unit, integration, regression, validation, system. OO Testing techniques Application of traditional techniques to OO software

Subversion. CS 490MT/5555, Fall 2015, Yongjie Zheng

18-642: Unit Testing 1/31/ Philip Koopman

Version Control Systems (VCS)

Announcements. CS18000: Problem Solving And Object-Oriented Programming

Jlint status of version 3.0

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

Code verification. CSE 331 University of Washington. Michael Ernst

Announcements. Lab tomorrow. Quiz Thursday P3 due Friday. Exceptions and unit testing

Build. System building

CS18000: Programming I

Motivating Example: Two Types of Errors (2) Test-Driven Development (TDD) with JUnit. Motivating Example: Two Types of Errors (1)

CS 3 Introduction to Software Engineering. 3: Exceptions

Topics in Software Testing

Version Control for Fun and Profit

Test-Driven Development (TDD) with JUnit

Maslab Software 2010

Technology Background Development environment, Skeleton and Libraries

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

An Introduction to Subversion

Development tools: Version control, build tools, and integrated development environments 1

Transcription:

CS18000: Programming I Testing Basics 19 April 2010 Prof. Chris Clifton Testing Programs Your programs are getting large and more complex How do you make sure they work? 1. Reason about the program Think carefully about what it does Not what you think it should do 2. Test But what to test for? 4/21/2010 CS18000 2 2010 Chris Clifton 1

Goals of Testing 1. Ensure program does what it should Does expected functions correctly. 2. Identify when program behaves improperly Does not behave badly when asked to do the unexpected. In practice, these are two different things! 1. Determine how to fix errors 2. Assist in program maintenance 4/21/2010 CS18000 3 Types of Testing Black-Box Testing Based purely on program specifications White-Box Testing Exercise the code (as written) Regression Testing Re-run tests when changes made 4/21/2010 CS18000 4 2010 Chris Clifton 2

Black-Box Tests Boundary Value Testing If known ranges of inputs, test at ends of ranges Both inside and outside of bounds Equivalence Partitioning Choose one (or more) from a group of functionally similar values All-Pairs Testing Test different pairs of input values Fuzz Testing Random choices of (potentially unlikely) values 4/21/2010 CS18000 5 Black-Box Testing Example Foo f[] = new Foo[maxF]; Foo checkfoo ( int top; boolean newfoo ) { /* If newfoo, return a new Foo. Otherwise check all Foo in f before top, return top. */ } Boundary Value Testing top=-1, 0, maxf, maxf+1 Equivalence Partitioning Negative top top where f not null top where f null top >maxf All-Pairs Testing Values for top with newfoo true values for top with newfoo false Fuzz Testing 4/21/2010 CS18000 6 2010 Chris Clifton 3

White-Box Tests Branch Testing Make sure every statement is exercised Ensure each side of a decision (if-then or loop) is taken Loop Testing Like boundary case testing for loops All-Paths testing Make sure every path through the program is tested Gets to be very expensive Exponential growth in number of cases 4/21/2010 CS18000 7 White-Box Testing Example Foo f[] = new Foo[maxF]; Foo checkfoo ( int top; boolean newfoo ) { /* If newfoo, return a new Foo. Otherwise check all Foo in f before top, return top. */ int i = 0; if ( newfoo ) return new Foo; while ( i < top ) f[i++].check(); return f[i]; } Branch Testing newfoo true newfoo false and top>0 Loop Testing newfoo false and: top <= 0 top = 1 top = maxf All-Paths Testing newfoo true newfoo false and top <= 0 newfoo false and top >= 0 4/21/2010 CS18000 8 2010 Chris Clifton 4

System Testing Test the entire program Testing Scope And the environment the system runs in Unit Testing Test individual modules Use skeletons / stub procedures, Driver code Integration Testing Test interfaces between units 4/21/2010 CS18000 9 Testing Tools Lots of automated support to Run tests Generate tests Take Software Engineering (CS 30700) to learn more JUnit: Unit Testing Tool for Java Generates tests But requires code be annotated 4/21/2010 CS18000 10 2010 Chris Clifton 5

JUnit Use 1. Download.jar file from http://www.junit.org 2. Add import org.junit.*; to class to be tested 3. Annotate methods to be tested @Test public void methodtotest() { } 4. Compile with JUnit javac classpath.;junit-4.5.jar ClassToTest.java 5. Run the tester on your code java classpath.;junit-4.5.jar org.junit.runner.junitcore ClassToTest 4/21/2010 CS18000 11 More on JUnit Can only test some methods public void return no arguments Additional annotations @Before: Run this method before any test @After: Run this method after any test Assertion extentions import static org.junit.assert.*; asserttrue( expression ); assertequals ( value1, value2 ); 4/21/2010 CS18000 12 2010 Chris Clifton 6

CS18000: Programming I Code Management 21 April 2010 Prof. Chris Clifton Managing Large Projects: Issues Keeping track of all the code Many classes / modules Multiple languages/systems Dealing with multiple developers Managing changes to an entire system Code Specifications / Requirements Documentation Development tools 4/21/2010 CS18000 14 2010 Chris Clifton 7

Tools to Help Build Management When we compile (install, etc.), ensure we don t forget anything Not just compilation Source code versioning repositories Track changes Keep old versions Manage concurrent changes 4/21/2010 CS18000 15 Build Management Tools javac compiles all needed files generates.class files from.java files recompiles any that have changed does it in the proper order (dependencies) Not built in to all compilers Need to specify Forgetting can lead to bad results 4/21/2010 CS18000 16 2010 Chris Clifton 8

What if? void caller() { String int } x = callee(3); I Recompile caller int String callee (int y) { } return y+1; Integer.toString(y+1); I forget to recompile callee 4/21/2010 CS18000 17 Solutions Compilation tools that check dependencies Works for things written in that language But what about other things? (e.g.,.java file generated from main.xml) Software Development Environments Eclipse Android SDK Make (primarily for Unix systems) 4/21/2010 CS18000 18 2010 Chris Clifton 9

Make General-purpose build management Independent of language Specify rules Dependencies Transformation Run make to perform transformations needed to meet dependencies make Lab13activity make TestLab13 make installonemulator make installonphone Lab13activity : Lab13activity.class LinkedList.class R.java : main.xml %.class : %.java javac %.java Really quite complex / powerful almost a programming language 4/21/2010 CS18000 19 Code Management Tools Safe storage Prevent accidental deletion Versioning Undo changes made in error Get back to a previous version Concurrency Multiple programmers don t overwrite each other s work Centralized Repository Developers work on their own machines 4/21/2010 CS18000 20 2010 Chris Clifton 10

Code Management Examples Language-specific software development environments Language independent tools RCS (Revision Control System) cvs (Concurrent Versions System) svn (Subversion) Each has advantages and disadvantages 4/21/2010 CS18000 21 Example: cvs Repository Directory in a file system Can be on a remote machine Never edit files in the repository Project Create initially with a set of files Stores these in the repository 4/21/2010 CS18000 22 2010 Chris Clifton 11

Example: cvs Checkout Get complete copy of a project from current files in the repository Update Bring checked out files up to date with repository Flag or merge files that you have changed and have been changed in the repository Commit Put your changes in the repository Creates a new version Requires that you add a comment (placed in each file updated) 4/21/2010 CS18000 23 Summary Large projects need added support Automation to prevent little mistakes Managing multiple developers Two key areas Build management Source code management Don t worry about the details now Go with what is in use wherever you are Just make sure you use something 4/21/2010 CS18000 24 2010 Chris Clifton 12