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

Similar documents
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

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

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

Modern Methods in Software Engineering. Testing.

Software Testing. Suppose you are asked:

Software Engineering (CSC 4350/6350) Rao Casturi

Agile Software Development. Lecture 7: Software Testing

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

Structural Testing. White Box Testing & Control Flow Analysis

Software Engineering Fall 2014

Chapter 11, Testing, Part 2: Integration and System Testing

Chapter 11, Testing, Part 2: Integration and System Testing

Test Driven Development Building a fortress in a greenfield (or fortifying an existing one) Dr. Hale University of Nebraska at Omaha

Fault, Error, and Failure

MONIKA HEINER.

Chapter 11, Testing, Part 2: Integration and System Testing

Chapter 11, Testing Part 1: Unit Testing. <M. Cossentino>

Software Testing Interview Question and Answer

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

Part 5. Verification and Validation

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

Topics in Software Testing

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Unit Testing. Emina Torlak

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

Introduction to Dynamic Analysis

Software Testing. Testing: Our Experiences

Verification and Validation

Lecture 15 Software Testing

Verification and Validation

Verification and Validation. Verification and validation

Verification and Validation

Program Correctness and Efficiency. Chapter 2

Software Engineering II Testing

Quality Assurance in Software Development

An Introduction to Systematic Software Testing. Robert France CSU

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

Facts About Testing. Cost/benefit. Reveal faults. Bottom-up. Testing takes more than 50% of the total cost of software development

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

Testing: Test design and testing process

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

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

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

Chapter 9. Software Testing

CMSC 132: OBJECT-ORIENTED PROGRAMMING II

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

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

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

Software Testing. Software Testing

Software Engineering Theory. Lena Buffoni (slides by Kristian Sandahl/Mariam Kamkar) Department of Computer and Information Science

1 Visible deviation from the specification or expected behavior for end-user is called: a) an error b) a fault c) a failure d) a defect e) a mistake

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

Darshan Institute of Engineering & Technology for Diploma Studies

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

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, September 18, ISSN SOFTWARE TESTING

Testing & Debugging TB-1

CS 4387/5387 SOFTWARE V&V LECTURE 4 BLACK-BOX TESTING

Object-Oriented Software Engineering Practical Software Development using UML and Java

Verification and Validation

Manuel Oriol, CHCRC-C, Software Testing ABB

Software Quality Assurance. David Janzen

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

Software Quality Assurance (SQA) Software Quality Assurance

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, April- ICITDA 18,

Topic: Software Verification, Validation and Testing Software Engineering. Faculty of Computing Universiti Teknologi Malaysia

Lecture 10: Introduction to Correctness

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

Chapter 8 Software Testing. Chapter 8 Software testing

Objectives. Chapter 19. Verification vs. validation. Topics covered. Static and dynamic verification. The V&V process

Software Testing CS 408

Introduction To Software Testing. Brian Nielsen. Center of Embedded Software Systems Aalborg University, Denmark CSS

Testing Process and Methods. CS 490MT/5555, Spring 2017, Yongjie Zheng

Chapter 15 Debugging

Higher-order Testing. Stuart Anderson. Stuart Anderson Higher-order Testing c 2011

Verification and Validation

UNIT-4 Black Box & White Box Testing

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

SOFTWARE ENGINEERING SOFTWARE VERIFICATION AND VALIDATION. Saulius Ragaišis.

UNIT-4 Black Box & White Box Testing

Chapter 9 Quality and Change Management

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

Sample Exam Syllabus

Program Analysis. Program Analysis

Bridge Course On Software Testing

Pearson Education 2007 Chapter 9 (RASD 3/e)

[IT6004-SOFTWARE TESTING] UNIT 2

INTRODUCTION TO SOFTWARE ENGINEERING

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

Software Testing. Software Testing. in the textbook. Chapter 8. Verification and Validation. Verification and Validation: Goals

COPYRIGHTED MATERIAL. Index

Testing Theory. Agenda - What will you learn today? A Software Life-cycle Model Which part will we talk about today? Theory Lecture Plan

Programming Embedded Systems

Certified Tester Foundation Level(CTFL)

340 Review Fall Midterm 1 Review

Software Testing. Software Testing. in the textbook. Chapter 8. Verification and Validation. Verification Techniques

Chap 2. Introduction to Software Testing

Chapter 7 Control Statements Continued

People tell me that testing is

Write perfect C code to solve the three problems below.

Transcription:

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

Outline Terminology Types of errors Dealing with errors Quality assurance vs Testing Component Testing! Unit testing! Integration testing Testing Strategy Design Patterns & Testing System testing! Function testing! Structure Testing! Performance testing! Acceptance testing! Installation testing Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2

What is this? A failure? An error? A fault? Need to specify the desired behavior first! Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3

Erroneous State ( Error ) Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4

Algorithmic Fault Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5

Mechanical Fault Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6

Terminology Reliability: The measure of success with which the observed behavior of a system confirms to some specification of its behavior. Failure: Any deviation of the observed behavior from the specified behavior. Error: The system is in a state such that further processing by the system will lead to a failure. Fault (Bug): The mechanical or algorithmic cause of an error. There are many different types of errors and different ways how we can deal with them. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7

How do we deal with Errors and Faults? Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8

Verification? Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9

Modular Redundancy? Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10

Declaring the Bug as a Feature? Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11

Patching? Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12

Testing? Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13

Examples of Faults and Errors Faults in in the the Interface specification! Mismatch between what the the client needs and and what the the server offers! Mismatch between requirements and and implementation Algorithmic Faults! Missing initialization! Branching errors (too (too soon, too too late) late)! Missing test test for for null null Mechanical Faults (very hard to to find)! Documentation does does not not match actual conditions or or operating procedures Errors! Stress or or overload errors! Capacity or or boundary errors! Timing errors! Throughput or or performance errors Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14

Dealing with Errors Verification:! Assumes hypothetical environment that does not match real environment! Proof might be buggy (omits important constraints; simply wrong) Modular redundancy:! Expensive Declaring a bug to be a feature! Bad practice Patching! Slows down performance Testing (this lecture)! Testing is never good enough Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15

Another View on How to Deal with Errors Error prevention (before the system is released):! Use good programming methodology to reduce complexity! Use version control to prevent inconsistent system! Apply verification to prevent algorithmic bugs Error detection (while system is running):! Testing: Create failures in a planned way! Debugging: Start with an unplanned failures! Monitoring: Deliver information about state. Find performance bugs Error recovery (recover from failure once the system is released):! Data base systems (atomic transactions)! Modular redundancy! Recovery blocks Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16

Some Observations It is impossible to completely test any nontrivial module or any system! Theoretical limitations: Halting problem! Practial limitations: Prohibitive in time and cost Testing can only show the presence of bugs, not their absence (Dijkstra) Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17

Testing takes creativity Testing often viewed as dirty work. To develop an effective test, one must have: " Detailed understanding of the system " Knowledge of the testing techniques " Skill to apply these techniques in an effective and efficient manner Testing is done best by independent testers! We often develop a certain mental attitude that the program should in a certain way when in fact it does not. Programmer often stick to the data set that makes the program work! "Don t mess up my code!" A program often does not work when tried by somebody else.! Don't let this be the end-user. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18

Testing Activities Subsystem Code Subsystem Code Unit Test Unit Test Tested Subsystem Tested Subsystem System Design Document Integration Test Integrated Subsystems Requirements Analysis Document Functional Test User Manual Functioning System Tested Subsystem Subsystem Code Unit Test All All tests tests by by developer Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19

Testing Activities continued Global Requirements Client s Understanding of Requirements User Environment Functioning System Performance Test Validated System Acceptance Test Accepted System Installation Test Tests by by developer Tests by by client User s understanding Tests (?) (?) by by user user System in Use Usable System Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20

Fault Handling Techniques Fault Handling Fault Avoidance Fault Detection Fault Tolerance Design Methodology Reviews Atomic Transactions Modular Redundancy Verification Configuration Management Testing Debugging Unit Testing Integration Testing System Testing Correctness Debugging Performance Debugging Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21

Quality Assurance encompasses Testing Quality Assurance Usability Testing Scenario Testing Prototype Testing Product Testing Fault Avoidance Fault Tolerance Verification Configuration Management Fault Detection Atomic Transactions Modular Redundancy Reviews Walkthrough Inspection Testing Debugging Unit Testing Integration Testing System Testing Correctness Debugging Performance Debugging Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22

Types of Testing Unit Testing:! Individual subsystem! 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! Carried out by developers! Goal: Test the interface among the subsystem Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23

System Testing System Testing:! The entire system! Carried out by developers! Goal: Determine if the system meets the requirements (functional and global) Acceptance Testing:! Evaluates the system delivered by developers! Carried out by the client. May involve executing typical transactions on site on a trial basis! Goal: Demonstrate that the system meets customer requirements and is ready to use Implementation (Coding) and testing go hand in hand Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24

Unit Testing Informal:! Incremental coding Static Analysis:! Hand execution: Reading the source code! Walk-Through (informal presentation to others)! Code Inspection (formal presentation to others)! Automated Tools checking for " syntactic and semantic errors " departure from coding standards Dynamic Analysis:! Black-box testing (Test the input/output behavior)! White-box testing (Test the internal logic of the subsystem or object)! Data-structure based testing (Data types determine test cases) Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25

Black-box Testing Focus: I/O behavior. If for any given input, we can predict the output, then the module passes the test.! Almost always impossible to generate all possible inputs ("test cases") Goal: Reduce number of test cases by equivalence partitioning:! 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) Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26

Black-box Testing (Continued) Selection of equivalence classes (No rules, only guidelines):! Input is valid across range of values. Select test cases from 3 equivalence classes: " Below the range " Within the range " Above the range! Input is valid if it is from a discrete set. Select test cases from 2 equivalence classes: " Valid discrete value " Invalid discrete value Another solution to select only a limited amount of test cases:! Get knowledge about the inner workings of the unit being tested => white-box testing Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27

White-box Testing Focus: Thoroughness (Coverage). Every statement in the component is executed at least once. Four types of white-box testing! Statement Testing! Loop Testing! Path Testing! Branch Testing Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28

White-box Testing (Continued) Statement Testing (Algebraic Testing): Test single statements (Choice of operators in polynomials, etc) Loop Testing:! Cause execution of the loop to be skipped completely. (Exception: Repeat loops)! Loop to be executed exactly once! Loop to be executed more than once Path testing:! Make sure all paths in the program are executed Branch Testing (Conditional Testing): Make sure that each possible outcome from a condition is tested at least once Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29

White-box Testing Example FindMean(float Mean, FILE ScoreFile) { SumOfScores = 0.0; NumberOfScores = 0; Mean = 0; Read(ScoreFile, Score); /*Read in and sum the scores*/ 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"); } Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30

White-box Testing Example: Determining 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 } 7 Read(ScoreFile, Score); 6 } /* 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 ); 9 4 8 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31

Constructing the Logic Flow Diagram Start 1 F 2 T 3 T F 4 5 6 7 T F 8 9 Exit Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32

Finding the Test Cases Start 1 a (Covered by any data) 2 b (Data set must contain at least one value) (Positive score) 3 d e (Negative score) c 4 5 (Data set must f g h (Reached if either f or be empty) 6 e is reached) (Total score < 0.0) i 7 j (Total score > 0.0) 8 9 k l Exit Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33

Comparison of White & Black-box Testing White-box Testing:! Potentially infinite number of paths have to be tested! White-box testing often tests what is done, instead of what should be done! Cannot detect missing use cases Black-box Testing:! Potential combinatorical explosion of test cases (valid & invalid data)! Often not clear whether the selected test cases uncover a particular error! Does not discover extraneous use cases ("features") Both types of testing are needed White-box testing and black box testing are the extreme ends of a testing continuum. Any choice of test case lies in between and depends on the following:! Number of possible logical paths! Nature of input data! Amount of computation! Complexity of algorithms and data structures Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34

The 4 Testing Steps 1. 1. Select what has to to be be measured! Analysis: Completeness of of requirements! Design: tested for for cohesion! Implementation: Code tests tests 2. 2. Decide how the the testing is is done! Code inspection! Proofs (Design by by Contract)! Black-box, white box, box,! Select integration testing strategy (big (big bang, bottom up, up, top top down, sandwich) 3. 3. Develop test cases! A test test case case is is a set set of of test test data data or or situations that that will will be be used used to to exercise the the unit unit (code, module, system) being tested or or about the the attribute being measured 4. 4. Create the the test oracle! An An oracle contains of of the the predicted results for for a set set of of test test cases! The The test test oracle has has to to be be written down before the the actual testing takes place Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35

Guidance for Test Case Selection Use analysis knowledge about functional requirements (black-box testing):! Use Use cases! Expected input data data! Invalid input data data Use design knowledge about system structure, algorithms, data structures (white-box testing):! Control structures " Test " Test branches, loops, loops,......! Data Data structures " Test " Test records records fields, fields, arrays, arrays,...... Use implementation knowledge about algorithms:! Examples:! Force division by by zero zero! Use Use sequence of of test test cases for for interrupt handler Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36

Unit-testing Heuristics 1. 1. Create unit unit tests tests as as soon soon as as object design is is completed:! Black-box test: test: Test Test the the use use cases & functional model! White-box test: test: Test Test the the dynamic model! Data-structure test: test: Test Test the the object model 2. 2. Develop the the test test cases! Goal: Find Find the the minimal number of of test test cases to to cover as as many paths as as possible 3. 3. Cross-check the the test test cases to to eliminate duplicates! Don't waste your your time! 4. 4. Desk Desk check your your source code code! Reduces testing time time 5. 5. Create a test test harness! Test Test drivers and and test test stubs are are needed for for integration testing 6. 6. Describe the the test test oracle! Often the the result of of the the first first successfully executed test test 7. 7. Execute the the test test cases! Don t forget regression testing! Re-execute test test cases every time time a change is is made. 8. 8. Compare the the results of of the the test test with with the the test test oracle! Automate as as much as as possible Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37