Review: SoBware Development

Similar documents
Objec&ves. Tes&ng 11/8/16. by Frederick P. Brooks, Jr., 1986

Objec&ves. Review. JUnit Coverage Collabora&on

Coverage tools Eclipse Debugger Object-oriented Design Principles. Oct 26, 2016 Sprenkle - CSCI209 1

Objec&ves. Review. So-ware Quality Metrics Sta&c Analysis Tools Refactoring for Extensibility

Designing a Social Network Prep for Lab 10. March 26, 2018 Sprenkle - CSCI Why classes and objects? How do we create new data types?

Objec&ves. Usability Project Discussion. May 9, 2016 Sprenkle - CSCI335 1

New features in Oracle 11g for PL/SQL code tuning.

Review of Lab 9. Review Lab 9. Social Network Classes/Driver Data. Lab 10 Design

11/15/13. Objectives. Review. Our Screen Saver Dependencies. Our Screen Saver Dependencies. Project Deliverables Timeline TEAM FINAL PROJECT

Google App Engine 8/10/17. CS Cloud Compu5ng Systems--Summer II 2017

Immigra6on Basics. Stephanie Paver, Senior A)orney. 1. Department of Homeland Security (DHS)

Lecture 8: Verification and Validation

There s a Cloud in My Enterprise

CSCI 325: Distributed Systems. Objec?ves. Professor Sprenkle. Course overview Overview of distributed systems Introduc?on to reading research papers

IDENTIFYING FAULT-PRONE MODULES IN SOFTWARE FOR DIAGNOSIS AND TREATMENT USING EEPORTERS CLASSIFICATION TREE

Records Reten+on Basics for ESDs Texas State Associa+on of Fire and Emergency Districts (SAFE-D) Annual Conference Galveston, TX February 24, 2018

Lab 11: Pair Programming. Review: Pair Programming Roles

TAFTW (Take Aways for the Week) APT Quiz and Markov Overview. Comparing objects and tradeoffs. From Comparable to TreeMap/Sort

Gary Hart, PhD. Partners

HANDS ACROSS BORDERS. An International Workshop on. Alterna(ve Mechanisms to Establish and Govern Transboundary Conserva(on Ini(a(ves

The 10- Year Framework of Programmes on Sustainable Consump=on & Produc=on. * An Intergovernmental mandate * Introduction

Servilla: Service Provisioning in Wireless Sensor Networks. Chenyang Lu

DevOps Course Content

1-1. Copyright 2015 Pearson Education, Inc.

Minimum Spanning Tree Union-Find Data Structure. Feb 28, 2018 CSCI211 - Sprenkle. Comcast wants to lay cable in a neighborhood. Neighborhood Layout

ISO/IEC20000 Overview and Cer2fica2on Approach

Bridging the Gap Between Legacy & Standards. d-wise. Bill Qubeck, Life Sciences Director

Best Prac*ces & Training Guide for Professional Development and Networking - June 2011-

Lecture Series - MSG 141 Technical Architecture and Standards C2- Simula:on Interoperability (C2SIM)

Decentralised solutions for renewable energies and water in developing countries

IBM Cognos Open Mic Cognos Analytics 11 Part nd June, IBM Corporation

Post contractual non-competition clauses

LMLIP Community Event 2013 Information Session

Online Ballots. Configuration and User Guide INTRODUCTION. Let Earnings Edge Assist You with Your Online Ballot CONTENTS

Text UI. Data Store Ø Example of a backend to a real Could add a different user interface. Good judgment comes from experience

Coali&on Ba*le Management Language (C- BML) and C2SIM History and Development

Estonian National Electoral Committee. E-Voting System. General Overview

Does Decentralization Lessen or Worsen Poverty? Evidence from

Philips Lifeline. Ø Chenyang Lu 1

Admission of TCN- Introduction. Constança Urbano de Sousa ULB, Brussels, 2 and 3 February 2013

OUR PANELISTS. Linda Morrison L&D Academy Administrator Travelex. Be+y Mills L&D Manager Centra Health. Ma+ Hart L&OD Resource Officer Metropolitan

One View Watchlists Implementation Guide Release 9.2

Chapter 8: Recursion

Dynamic Games Lesson 4: Economic Aplica4ons. Universidad Carlos III

Cover page design by Udara Jayawardhane. The cover image is for visual effect only and does not imply the expression of any opinion whatsoever on the

SCHOOLMASTER. Appointment Scheduling. Student Information Systems. Revised - August Schoolmaster is SIF Certified

Cross- Campus Enrollment System Project Update. December, 2015

JD Edwards EnterpriseOne Applications

UTAH LEGISLATIVE BILL WATCH

A Call for a Migra7on Consensus

Acceptance Testing More Important Than Ever. Texas Association of Election Administrators January 10, 2018

Adaptive QoS Control for Real-Time Systems

The idea of just war theory

My Health Online 2017 Website Update Online Appointments User Guide

Hoboken Public Schools. PLTW Introduction to Computer Science Curriculum

Private Sponsorship in Refugee Resettlement. February 2017

This manual represents a print version of the Online Filing Help.

Plan For the Week. Solve problems by programming in Python. Compsci 101 Way-of-life. Vocabulary and Concepts

Sage 100 Fund Accounting. Bank Reconciliation STUDENT WORKBOOK SAGE LEARNING SERVICES. Important Notice:

Thinking Like a Computer Scien4st About Ancient Roman Graffi4

LS C2 to Simula0on Interoperability (C2SIM) - Lessons learned Near Future: plans for opera0onaliza0on

Fall 2016 COP 3223H Program #5: Election Season Nears an End Due date: Please consult WebCourses for your section

TNAU Weather so. Weather Database cum weather analysis so.ware

Support Vector Machines

Results of L Année philologique online OpenURL Quality Investigation

General Framework of Electronic Voting and Implementation thereof at National Elections in Estonia

BaxEnergy GmbH ( BaxEnergy ) Software License and Services Agreement

Need for a uniform European registra2on system for volunteer par2cipa2on? Annick Peremans Research Centre Aalst Belgium

Ballot Reconciliation Procedure Guide

MSL. Mul'-Robot Manipula'on without Communica'on. Zijian Wang and Mac Schwager

LPGPU. Low- Power Parallel Compu1ng on GPUs. Ben Juurlink. Technische Universität Berlin. EPoPPEA workshop

Incumbency as a Source of Spillover Effects in Mixed Electoral Systems: Evidence from a Regression-Discontinuity Design.

FM Legacy Converter User Guide

Assumption of TOBT Responsibility and Usage Agreement HAM CSA

Analyzing proofs Introduction to problem solving. Wiki: Everyone log in okay? Decide on either using a blog or wiki-style journal?

HOW TO RUN AN ONLINE ELECTION

Using CAS Cross-Functional Frameworks to Facilitate a Collaborative FYE Approach

Access to informa.on: Lessons from Fukushima Nuclear Accident

Final Review. Chenyang Lu. CSE 467S Embedded Compu5ng Systems

Child Check In Quick Start Guide. v 9.5. Local: (706) Atlanta: (404) Toll Free: (866)

CHALLENGES ASSOCIATED WITH HOUSING NEWCOMERS IN SMALL AND MID- SIZED COMMUNITIES

About The Beta Participant Agreement

Tariffs and Tariff Comparison

Fairsail Country Pack: U.S.A.

Interpre'ng our Results & Condi'onal Effects. Andrea Ruggeri WK 2 Q Step, Year 2

Unilateral Powers. Ryan D. Williamson

Question 1. Does your library plan to remain in the Federal Depository Library Program?

Immigra'on Se-lement Services and Gaps in Yukon, Northwest Territories and Nunavut

CSE 308, Section 2. Semester Project Discussion. Session Objectives

Using the TrialWorks Docket Tab

CSE 520S Real-Time Systems

Applica'on of UQ Principles to Calibra'on, Sensi'vity, and Experimental Design

ForeScout Extended Module for McAfee epolicy Orchestrator

SOFTWARE END USER LICENSE AGREEMENT

Clause Logic Service User Interface User Manual

M-Vote (Online Voting System)

Abila MIP Fund Accounting TM. Bank Reconciliation STUDENT WORKBOOK ABILA LEARNING SERVICES. Important Notice:

ADVANCED SCHEDULING - OVERVIEW OF CHANGES COMING AUGUST 2014

City of Toronto Election Services Internet Voting for Persons with Disabilities Demonstration Script December 2013

VoteCastr methodology

Transcription:

Objec&ves Tes&ng Oct 12, 2016 Sprenkle - CSCI209 1 Review: SoBware Development From Monday Oct 12, 2016 Sprenkle - CSCI209 2 1

CLASSPATH Oct 12, 2016 Sprenkle - CSCI209 3 Classpath Tells the compiler or JVM where to look for userdefined classes and packages Ø OBen when using third-party libraries Similar to PYTHONPATH Typically know it needs to be set when there are class not found error messages Oct 12, 2016 Sprenkle - CSCI209 4 2

SeRng the Classpath Can specify classpath in command line javac -cp path/to/myjavaclasses MyClass.java java cp path/to/myjavaclasses MyClass Can specify the classpath environment variable Ø Edit your.bash_profile OR Ø Set in terminal CLASSPATH=$CLASSPATH:path/to/myjavaclasses echo $CLASSPATH Current value of CLASSPATH In Eclipse, you can Configure Build Path for a project Oct 12, 2016 Sprenkle - CSCI209 5 SOFTWARE TESTING PROCESS Oct 12, 2016 Sprenkle - CSCI209 6 3

Why Test Programs? Consider an online bookstore Bug! Customer sees bug Site Goes Down for Maintenance (a.k.a., a fault) Customers choose a competitor s site Lose customers confidence Oct 12, 2016 Sprenkle - CSCI209 7 MicrosoB Tes&ng Beyond their internal tes&ng Ø 5 million people beta tested Ø 60+ years of performance tes&ng Ø 1 Billion+ Office 2007 sessions S&ll, users found correctness, stability, robustness, and security bugs Oct 12, 2016 Sprenkle - CSCI209 8 4

Type 1 Bugs: Compile-Time Syntax errors Ø Missing semicolon, parentheses Compiler no&fies of error Cheap, easy to fix Oct 12, 2016 Sprenkle - CSCI209 9 Type 2 Bugs: Run-Time Usually logic errors Expensive to locate, fix Oct 12, 2016 Sprenkle - CSCI209 10 5

Aside: Objec&ons to Bug Terminology Bug Ø Sounds like it s just an annoyance Can simply swat away Ø Minimizes poten&al problems Ø Hides programmer s responsibility Alterna&ve terms Ø Defect Ø Fault Oct 12, 2016 Sprenkle - CSCI209 11 SoBware Tes&ng Process Input Program Output Test Case Program Under Test Expected Output? Test Suite: set of test cases pass or fail Oct 12, 2016 Sprenkle - CSCI209 12 6

SoBware Tes&ng Process Input Program Output Tester plays devil s advocate Ø Hopes to reveal problems in the program using good test cases Ø Beher tester finds than a customer! How is testing different from debugging? Oct 12, 2016 Sprenkle - CSCI209 13 How Would You Test a Calculator Program? Input Calculator Program Output Operands, operators, expected output adds, subtracts, multiplies, divides Numerical Answer What test cases: input and expected output? Oct 12, 2016 Sprenkle - CSCI209 14 7

Example Test Cases for Calculator Program Basic Func&onality Ø Addi&on Ø Subtrac&on Ø Mul&plica&on Ø Division Ø Order of opera&ons Invalid Input Ø Lehers, not-opera&on characters (&,$, ) Tricky Cases Ø Divide by 0 Ø Nega&ve Numbers Ø Long sequences of operands, operators Ø VERY large, VERY small numbers Oct 12, 2016 Sprenkle - CSCI209 15 Types of Tes&ng (Non-Exhaus&ve) Black-box tes&ng Non-func&onal tes&ng White-box tes&ng Acceptance tes&ng Ideas or definitions of any of these? Oct 12, 2016 Sprenkle - CSCI209 16 8

Types of Tes&ng (Non-Exhaus&ve) Black-box tes&ng Ø Test func%onality (e.g., the calculator) Ø No knowledge of the code Ø Examples of tes&ng: boundary values White-box tes&ng Ø Have access to code Ø Goal: execute all code Non-func&onal tes&ng Ø Performance tes&ng Ø Usability tes&ng (HCI) Ø Security tes&ng Ø Interna&onaliza&on, localiza&on Acceptance tes&ng Ø Customer tests to decide if accepts product Oct 12, 2016 Sprenkle - CSCI209 17 Levels of Tes&ng Unit Ø Tests minimal sobware component, in isola&on Ø For us, Class-level tes&ng Ø Web: Web pages (Hhp Request) Integra&on Ø Tests interfaces & interac&on of classes System Ø Tests that completely integrated system meets requirements System Integra&on Ø Test system works with other systems, e.g., thirdparty systems Cost increases Oct 12, 2016 Sprenkle - CSCI209 18 9

UNIT TESTING Oct 12, 2016 Sprenkle - CSCI209 19 Why Unit Test? Verify code works as intended in isola&on Find defects early in development Ø Easier to test small pieces Ø Less cost than at later stages Oct 12, 2016 Sprenkle - CSCI209 20 10

Why Unit Test? Verify code works as intended in isola&on Find defects early in development Ø Easier to test small pieces Ø Less cost than at later stages As applica&on evolves, new code is more likely to break exis&ng code Ø Suite of (small) test cases to run aber code changes Ø Also called regression tes&ng Oct 12, 2016 Sprenkle - CSCI209 21 Some Approaches to Tes&ng Methods Typical case Ø Test typical values of input/parameters Boundary condi&ons Ø Test at boundaries of input/parameters Ø Many faults live in corners Parameter valida&on Ø Verify that parameter and object bounds are documented and checked Ø Example: pre-condi&on that parameter isn t null All black-box testing approaches Oct 12, 2016 Sprenkle - CSCI209 22 11

Another Use of Unit Tes&ng: Test-Driven Development A development style, evolved from Extreme Programming Idea: write tests first without code bias How do you know you re done in traditional development? The Process: 1. Write tests that code/new func&onality should pass Like a specifica&on for the code (pre/post condi&ons) All tests will ini&ally fail 2. Write the code and verify that it passes test cases Know you re done coding when you pass all tests What assumption does this make? Oct 12, 2016 Sprenkle - CSCI209 23 SoBware Tes&ng Issues How should you test? How oben? Ø Code may change frequently Ø Code may depend on others code Ø A lot of code to validate How do you know that an output is correct? Ø Complex output Ø Human judgment? What caused a code failure? Need a systematic, automated, repeatable approach Oct 12, 2016 Sprenkle - CSCI209 24 12

Characteris&cs of Good Unit Tes&ng AutomaAc Thorough Repeatable Independent Why are these characteristics of good (unit) testing? Oct 12, 2016 Sprenkle - CSCI209 25 JUNIT Oct 12, 2016 Sprenkle - CSCI209 26 13

JUnit Framework A framework for unit tes&ng Java programs Ø Supported by Eclipse and other IDEs Ø Developed by Erich Gamma and Kent Beck Func&onality Ø Write tests Validate output, automa&cally Ø Automate execu&on of test suites Ø Display pass/fail results of test execu&on Stack trace where fails Ø Organize tests, separate from code But, you s&ll need to come up with the tests! Erich Gamma Kent Beck Oct 12, 2016 Sprenkle - CSCI209 27 Tes&ng with JUnit Typical organiza&on: Ø Set of tes&ng classes tests CDTest DVDTest MediaItemTest Ø Tes&ng classes packaged together in a tests package Separate package from code tes&ng A test class typically Ø Focuses on a specific class Ø Contains methods, each of which represents another test of the class Oct 12, 2016 Sprenkle - CSCI209 28 14

Structure of a JUnit Test 1. Set up the test case (op&onal) Ø Example: Crea&ng objects 2. Exercise the code under test 3. Verify the correctness of the results 4. Teardown (op&onal) Ø Example: reclaim created objects Oct 12, 2016 Sprenkle - CSCI209 29 Annota&ons Tes&ng in JUnit 4: uses annotaaons Provide data about a program that is not part of program itself Have no direct effect on opera&on of the code Example uses: Ø @Override: method declara&on is intended to override a method declara&on in parent class If method does not override parent class method, compiler generates error message Ø Informa&on for the compiler to suppress warnings (@SupressWarnings) Oct 12, 2016 Sprenkle - CSCI209 30 15

Tests are Methods Mark your tes&ng method with @Test Ø From org.junit.test public class CalculatorTest { } @Test public void addtest() { } Class for testing the Calculator class A method to test the add functionality Conven&on: Method name describes what you re tes&ng Oct 12, 2016 Sprenkle - CSCI209 31 Assert Methods Variety of assert methods available If fail, throw an excep&on Otherwise, test keeps execu&ng All static void Example: assertequals(object expected, Object actual) @Test public void addtest() { assertequals(4, calculator.add(3, 1)); } Oct 12, 2016 Sprenkle - CSCI209 32 16

Assert Methods To use asserts, need sta%c import: import static org.junit.assert.*; Ø static allows us to not have to use classname More examples Ø asserttrue(boolean condition) Ø assertsame(object expected, Object actual) Refer to same object Ø assertequals(double expected, double actual, double delta) Oct 12, 2016 Sprenkle - CSCI209 33 Example Uses of Assert Methods @Test public void testemptycollection() { Collection collection = new ArrayList(); asserttrue(collection.isempty()); } assertequals(double expected, double actual, double delta) @Test public void testpi() { final double ERROR_TOLERANCE =.01; assertequals(math.pi, 3.14, ERROR_TOLERANCE); } Will fail if ERROR_TOLERANCE =.001 Oct 12, 2016 Sprenkle - CSCI209 34 17

Set Up/Tear Down May want methods to set up objects for every test in the class Ø Called fixtures Ø If have mul&ple, no guarantees for order executed @Before public void preparetestdata() {... } @Before public void setupmocks() {... } @After public void cleanuptestdata() {... } Executed before each test method Oct 12, 2016 Sprenkle - CSCI209 35 Example Set Up Method private CD testcd; @Before public void setup() { testcd = new CD("CD title", 100, 1997, "CD Artist", 11); } @Before Executed before each test method Can use testcd in test methods Oct 12, 2016 Sprenkle - CSCI209 36 18

Expec&ng an Excep&on Handling Error Cases Ø Some&mes an excep&on is the expected result Add an expected attribute: @Test(expected=IndexOutOfBoundsException.class) public void testindexoutofboundsexception() { ArrayList emptylist = new ArrayList(); Object o = emptylist.get(0); } Test case passes iff exception thrown Oct 12, 2016 Sprenkle - CSCI209 37 Set Up/Tear Down For Class May want methods to set up objects for set of tests Ø Executed once before any test in class executes @BeforeClass public static void setupdatabaseconnection() {... } @AfterClass public static void teardowndatabaseconnection() {... } Oct 12, 2016 Sprenkle - CSCI209 38 19

JUNIT IN ECLIPSE Oct 12, 2016 Sprenkle - CSCI209 39 Using JUnit in Eclipse Eclipse can help make our job easier Ø Automa&cally execute tests (i.e., methods) Ø We can focus on coming up with tests Oct 12, 2016 Sprenkle - CSCI209 40 20

Using JUnit in Eclipse In Eclipse, go to your MediaItem project Create a new JUnit Test Case (under Java) Ø Use JUnit 4 Add junit to build path Ø Put in package media.tests Ø Name: DVDTest Ø Choose to test DVD class Select setup and teardown Select methods to test Run the class as a JUnit Test Case Oct 12, 2016 Sprenkle - CSCI209 41 Example Test method that gets the length of the DVD Ø Revise: Add code to setup method that creates a DVD Notes Ø Replaying all the test cases: right click on package Ø FastView vs Detached Ø Hint: CTL-Spacebar to get auto-complete op&ons Oct 12, 2016 Sprenkle - CSCI209 42 21

Unit Tes&ng & JUnit Summary Unit Tes&ng: tes&ng smallest component of your code Ø For us: class and its methods JUnit provides framework to write test cases and run test cases automa&cally Ø Easy to run again aber code changes JUnit Resources available from Course Page s Resource Link, under Java Ø API Ø Tutorials Oct 12, 2016 Sprenkle - CSCI209 43 22