Agile Software Development. Lecture 7: Software Testing

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

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

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

Structural Testing. White Box Testing & Control Flow Analysis

Introduction to JUnit

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

Object-Oriented Software Engineering Conquering Complex and Changing Systems. Chapter 9, Testing

CS18000: Programming I

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

Tuesday, November 15. Testing

Test automation / JUnit. Building automatically repeatable test suites

Introduction to Programming. Lecture 2: Introduction to C

Testing. Outline. What is this? Terminology. Erroneous State ( Error ) Algorithmic Fault

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

Lecture 15 Software Testing

EECS 4313 Software Engineering Testing

Test automation / JUnit. Building automatically repeatable test suites

Test automation Test automation / JUnit

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

Software Testing. Lecturer: Sebastian Coope Ashton Building, Room G.18

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

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

Testing Stragegies. Black Box Testing. Test case

Software Testing. Suppose you are asked:

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

Test-Driven Development JUnit

Topics in Software Testing

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

Software Engineering I (02161)

xtreme Programming (summary of Kent Beck s XP book) Stefan Resmerita, WS2015

An Introduction to Systematic Software Testing. Robert France CSU

OHJ-306x: Software Testing Introduction to the Course Project Part 1: General Information and Project phases 1 & 2: Unit testing

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

White box testing. White-box testing. Types of WBT 24/03/15. Advanced Programming

Manuel Oriol, CHCRC-C, Software Testing ABB

Program Verification! Goals of this Lecture! Words from the Wise! Testing!

Tools for Unit Test - JUnit

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

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

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

linaye/gl.html

Test-Driven Development JUnit

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore

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

Modern Methods in Software Engineering. Testing.

Verification and Validation. Assuring that a software system meets a user s needs. Verification vs Validation. The V & V Process

Chapter 3. Unit Testing with JUnit and Debugging. Testing with JUnit getting started. Note

JUnit in EDA Introduction. 2 JUnit 4.3

Darshan Institute of Engineering & Technology for Diploma Studies

Software Testing Lecture 1. Justin Pearson

Chapter 9. Software Testing

Topics. Software Testing Test Driven Development Black Box Testing Unit Testing White Box Testing Coverage Testing Software Debugging

Testing. Technion Institute of Technology Author: Assaf Israel. Author: Assaf Israel - Technion

Tools for Unit Test JUnit

Object Oriented Software Design - I

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

CS159. Nathan Sprague. September 30, 2015

(Refer Slide Time: 1:27)

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

Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II

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

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

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

Introduc)on to tes)ng with JUnit. Workshop 3

Program Correctness and Efficiency. Chapter 2

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

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

Problem other classes messing with my stuff!

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

CSE 331 Midterm Exam Sample Solution 2/13/12

Programming Embedded Systems

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

Utilizing Fast Testing to Transform Java Development into an Agile, Quick Release, Low Risk Process

Introduction to Programming. Lecture 6: Functions & Program Structure

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

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

CMSC 132: OBJECT-ORIENTED PROGRAMMING II

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

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

Software Engineering (CSC 4350/6350) Rao Casturi

Software Engineering I (02161)

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

Chap 2. Introduction to Software Testing

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

Software Engineering and Scientific Computing

Program Analysis. Program Analysis

F. Tip and M. Weintraub FUNCTIONAL TESTING

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Software Engineering Fall 2014

Testing on Steriods EECS /30

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

Introduction to JUnit. Data Structures and Algorithms for Language Processing

JUnit on Eclipse. Chien-Tsun Chen Sep. 23, 2003

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

MTAT : Software Testing

Provided Files that Are Fine

MTAT : Software Testing

Visual Programming. Lecture 3: Loops, Arrays. Mahmoud El-Gayyar

Compiling with Multiple Files The Importance of Debugging CS 16: Solving Problems with Computers I Lecture #7

Testing and Debugging

Transcription:

Agile Software Development Lecture 7: Software Testing Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Slides are a modified version of the slides by Prof. Kenneth M. Anderson

Outline Testing Terminology Types of Testing Unit Testing Black-Box Testing White-Box Testing JUnit (Testing in Java)

What is Testing? Testing: Find the differences between the expected behavior and the observed behavior. Goal: Design tests that exercise defects in the system and to reveal problems A successful test is a test that identifies faults

Type of Errors Fault (Bug): A design or coding mistake that may cause abnormal component behavior. Error: The system is in a state such that further processing by the system will lead to a failure. Failure: Any perceivable deviation of the observed behavior from the specified behavior. Human fault Error Failure

Test Cases Test Case: set of input data and expected results that exercise a component with the purpose of causing failures and detecting faults Test cases can have relationships: T4: TestCase T1: TestCase precedes precedes T5: TestCase T2: TestCase T3: TestCase

Test Stub and Drivers Test Driver: simulates the part of the system that calls the component under test (CUT) Test Stub (or Mock): simulates component that are called by the tested component Not always a trivial task use TestStub TestDriver calls aclass: MyClass use TestStub

Type of Testing Unit Testing: Individual subsystem (modules) Carried out by developers Goal: Confirm that subsystems is correctly coded and carries out the intended functionality Integration Testing: Groups of subsystems (collection of classes) and eventually the entire System to ensure that modules work together correctly Carried out by developers or test team Goal: Test the interface among the subsystem

System Testing: The entire system Type of Testing Carried out by test team (developers shouldn t be involved) Goal: Determine if the system meets the requirements (functional and global) Functional Testing: Test of functional requirements Performance Testing: Test of non-functional requirements Acceptance Tests performed by users to check that the delivered system meets their needs In large, custom projects, developers will be on-site to install system and then respond to problems as they arise

Black Box Testing Multi-Level Testing Does the system behave as predicted by its specification White Box Testing Since, we have access to most of the code, lets make sure we are covering all aspects of the code: statements, branches, Gray Box Testing Having a bit of insight into the architecture of the system, does it behave as predicted by its specification

Black-Box Testing IN Black Box OUT Test Data Expected Data Actual Data Ideally: All possible value Unmanagable! To expensive! => Equivalence classes Comparison of expected and actual data

Black-Box Testing Focus: I/O behavior. If for any given input we can predict the output, then the module passes the test. Do not deal with the internal aspects of the tested component Almost always impossible to generate all possible inputs Goal: Reduce number of test cases Method: Equivalence Testing Divide input conditions into equivalence classes Choose test cases for each equivalence class. (Example: If an object is supposed to accept a negative number, testing one negative number is enough)

Square Root Function Equivalence Classes Negative, Zero, Positive Test data = {-16, 0, 25}, Expected Result = {4, 0, 5} In a computer store, the computer item can have a quantity between -500 to +500. What are the equivalence classes? Valid class: -500 <= QTY <= +500 Invalid class: QTY > +500 Invalid class: QTY < -500

Gray Box Testing Use knowledge of system s architecture to create a more complete set of black box tests Verifying logging information for each function is the system really updating all internal state correctly Data destined for other systems Looking for Scraps Is the system correctly cleaning up after itself temporary files, memory leaks, data duplication/deletion

Your time!! Exercise : Black and Gray box testing Mahmoud El-Gayyar / Software Engineering 14

White-Box Testing Focus on the internal structureof the component. Goal: Each state in dynamic model of an object and each interaction among the objects should be tested. Four quality metrics for white-box testing: Statement Coverage Is each statement exercised(covered) by a test? Loop Coverage Is each loop body executed zero times, exactly once, and more than once (consecutively)? Branch Coverage Is each possible outcome of an decision covered? Path Coverage Is each possible path covered?

Example: White-Box Testing findmean(file ScoreFile){ float SumOfScores = 0.0; int NumberOfScores = 0; float Mean=0.0; float Score; Read(ScoreFile, Score); while!eof(scorefile) { if (Score > 0.0 ) { SumOfScores = SumOfScores + Score; NumberOfScores++; } } Read(ScoreFile, Score); } /* Compute the mean and print the result */ if (NumberOfScores > 0) { Mean = SumOfScores / NumberOfScores; printf( The mean score is %f\n, Mean); } else printf ( No scores found in file\n );

Example: White-Box Testing: Determine the paths findmean(file ScoreFile) { float SumOfScores = 0.0; int NumberOfScores = 0; 1 float Mean=0.0; float Score; Read(ScoreFile, Score); 2 while!eof(scorefile) { 3 if (Score > 0.0 ) { SumOfScores = SumOfScores + Score; NumberOfScores++; } 5 Read(ScoreFile, Score); 6 } /* Compute the mean and print the result */ 7 if (NumberOfScores > 0) { Mean = SumOfScores / NumberOfScores; printf( The mean score is %f\n, Mean); } else printf ( No scores found in file\n ); } 4 9 8

Constructing the Logic Flow Diagram Start 1 F 2 T 3 T F 4 5 6 7 T F 8 9 Exit

Finding Test Cases Start + score Empty data set c 1 a 2 b d 3 e 4 5 f g 6 h (Covered by any data) At least one value is required - score Reached if either f or e is reached 7 Total score >0.0 i j Total score <=0.0 8 9 k l Exit

Tools that can track code coverage metrics for you (mostly just statement and branch coverage) Ex: EclEmma for Java Code Coverage Tools 13

Test Automation It is important that your tests be automated More likely to be run More likely to catch problems as changes are made testing frameworks allow tests to be run with a single command e.g. JUnit for JAVA (but there are lots of testing frameworks out there) Test presentation!!!!! 13

De facto standard Java framework for unit (object) testing JUnit helps the programmer: Testing in Java: JUnit define and execute tests and test suites write and debug code integrate code and always be ready to release a working version JUnit is not included in Sun s SDK, but almost all IDEs include it

Junit: Terminology A test fixture sets up the data (both objects and primitives) that are needed to run tests Example: If you are testing code that updates an employee record, you need an employee record to test it on A test case tests the response of a single method to a particular set of inputs A test suite is a collection of test cases

A Simple Example Suppose you have a class Arithmetic with static methods int multiply(int x,int y) boolean ispositive(int x) import org.junit.*; Import static org.junit.assert.*; public Class ArithmaticTest{ @Test } public void testmultiply(){ } assertequals(4, Arithmetic.multiply(2,2)); assertequals(4,arithmetic.multiply(3,-5)); @Test public void testispositive(){ } asserttrue( Arithmetic.isPositive(2)); assertfalse( Arithmetic.isPositive(-2)); assertfalse( Arithmetic.isPositive(0));

Test Suites You can define a suite of tests import org.junit.runner.runwith; import org.junit.runners.suite; import org.junit.runners.suite.suiteclasses; @RunWith(Suite.class) @Suite.SuiteClasses({ }) FirstTest.class, SecondTest.class, ThirdTest.class public Class AllTests(){ }

JUnit in Eclipse I Bar is green if all tests pass, red otherwise Ran 10 of the 10 tests No tests failed, but... Something unexpected happened in two tests This test passed This is how long the test took Something is wrong Depending on your preferences, this window might show only failed tests

JUnit in Eclipse II

Continuous Integration Since test automation is so critical, systems known as continuous integration frameworks (CI) have emerged CI systems wrap version control, compilation, and testing into a single repeatable process

Summary Testing Terminology Types of Testing Multi-Level Testing Black-Box Testing Gray-Box Testing White-Box Testing Test Automation and Continuous Integration