Object Oriented Testing and Test-Driven Development

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Unit-V testing strategies and tactics.
Design by Contract.
Software Testing. Quality is Hard to Pin Down Concise, clear definition is elusive Not easily quantifiable Many things to many people You'll know it when.
Unit Testing in the OO Context(Chapter 19-Roger P)
Software Engineering Object Oriented Testing James Gain
Alternate Software Development Methodologies
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
November 2005J. B. Wordsworth: J5DAMQVT1 Design and Method Quality, Verification, and Testing.
Object-oriented Testing SIM3302. Objectives To cover the strategies and tools associated with object oriented testing  Analysis and Design Testing 
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Chapter 1 Principles of Programming and Software Engineering.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Types and Techniques of Software Testing
Software Engineering Lecture 13 Software Testing Strategies 1.
Chapter 13 & 14 Software Testing Strategies and Techniques
System Testing There are several steps in testing the system: –Function testing –Performance testing –Acceptance testing –Installation testing.
Programinės Įrangos Testavimo Strategijos
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
These slides are designed to accompany Software Engineering: A Practitioner’s Approach, 7/e (McGraw-Hill 2009). Slides copyright 2009 by Roger Pressman.1.
1 Object-Oriented Testing CIS 375 Bruce R. Maxim UM-Dearborn.
These slides are designed to accompany Software Engineering: A Practitioner’s Approach, 7/e (McGraw-Hill 2009). Slides copyright 2009 by Roger Pressman.1.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
1 Software Testing (Part-II) Lecture Software Testing Software Testing is the process of finding the bugs in a software. It helps in Verifying and.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 13b: Software Testing Strategies Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
1 Software Engineering Muhammad Fahad Khan Software Engineering Muhammad Fahad Khan University Of Engineering.
1 Chapter 7 Software Testing Strategies. 2 Software Testing Testing is the process of exercising a program with the specific intent of finding errors.
These slides are designed to accompany Software Engineering: A Practitioner’s Approach, 7/e (McGraw-Hill 2009). Slides copyright 2009 by Roger Pressman.1.
Object Oriented Testing: An Overview
TESTING LEVELS Unit Testing Integration Testing System Testing Acceptance Testing.
Chapter : 19 Testing Object-Oriented Applications.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
LECTURE 19 23/11/15 Software Quality and Testing.
Software Engineering Saeed Akhtar The University of Lahore.
Software Testing and Quality Assurance 1. What is the objectives of Software Testing?
Chapter 24 객체지향 응용프로그램 테스팅 Testing Object-Oriented Applications 임현승 강원대학교 Revised from the slides by Roger S. Pressman and Bruce R. Maxim for the book.
1 Software Testing Strategies: Approaches, Issues, Testing Tools.
Chapter 9 Object Oriented Testing. Objectives lTo cover the strategies and tools associated with object oriented testing  Analysis and Design Testing.
1 Lecture 15: Chapter 19 Testing Object-Oriented Applications Slide Set to accompany Software Engineering: A Practitioner’s Approach, 7/e by Roger S. Pressman.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
Software Engineering By Germaine Cheung Hong Kong Computer Institute Lecture 7.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 14b: Software Testing Techniques Software Engineering: A Practitioner’s Approach, 6/e Chapter.
VI SEM CSE UNIT IV SOFTWARE ENGINEERING PROJECT MANAGEMENT TESTING STRATEGIES By Mr. Vaibhav V. Bhujade DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING DMIETR,
OBJECT-ORIENTED TESTING. TESTING OOA AND OOD MODELS Analysis and design models cannot be tested in the conventional sense. However, formal technical reviews.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
Requirement Elicitation Review – Class 8 Functional Requirements Nonfunctional Requirements Software Requirements document Requirements Validation and.
Lecturer: Eng. Mohamed Adam Isak PH.D Researcher in CS M.Sc. and B.Sc. of Information Technology Engineering, Lecturer in University of Somalia and Mogadishu.
 The processes used for RE vary widely depending on the application domain, the people involved and the organisation developing the requirements.  However,
Software Testing Strategies for building test group
Software Engineering: A Practitioner’s Approach, 6/e Chapter 13 Software Testing Strategies copyright © 1996, 2001, 2005 R.S. Pressman & Associates,
Chapter 13 & 14 Software Testing Strategies and Techniques
Object Oriented Testing
Chapter 24 Testing Object-Oriented Applications
Lecture 09:Software Testing
Static Testing Static testing refers to testing that takes place without Execution - examining and reviewing it. Dynamic Testing Dynamic testing is what.
Chapter 17 Software Testing Strategies
Chapter 19 Testing Object-Oriented Applications
Chapter 10 – Software Testing
System Testing.
Chapter 17 Software Testing Strategies
Chapter 19 Testing Object-Oriented Applications
Chapter 17 Software Testing Strategies.
Chapter 17 Software Testing Strategies
Chapter 11: Integration- and System Testing
Chapter 17 Software Testing Strategies
Software Testing Strategies
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Presentation transcript:

Object Oriented Testing and Test-Driven Development Based on notes from James Gain (jgain@cs.uct.ac.za) Larman, chapter 21 and notes on Larman from George Blank of NJIT plus Glenn Blank’s elaborations and expansions

Objectives To discuss when testing takes place in the life cycle ? Test-driven development advocates early testing! To cover the strategies and tools associated with object oriented testing Analysis and Design Testing Class Tests Integration Tests Validation Tests System Tests To discuss test plans and execution for projects ? analysis design code test

Object-Oriented Testing When should testing begin? Analysis and Design: Testing begins by evaluating the OOA and OOD models How do we test OOA models (requirements and use cases)? How do we test OOD models (class and sequence diagrams)? Structured walk-throughs, prototypes Formal reviews of correctness, completeness and consistency Programming: How does OO make testing different from procedural programming? Concept of a ‘unit’ broadens due to class encapsulation Integration focuses on classes and their context of a use case scenario or their execution across a thread Validation may still use conventional black box methods

Test-driven programming eXtreme Programming (XP) advocates writing tests for units before writing actual code for units Why might this practice be a good idea? Constrains code to design: How so? Design -> Test -> Code … in small iterations Promotes validation and reliability: Why? Always rerun all tests (easier with automated testing) before integrating new code in a release Increases confidence to change code: Why? Changes shouldn’t break old code if you can test old code Creed of XP: “embrace change”

The Bug Curve

Criteria for Completion of Testing When are we done testing? (Are we there yet?) How to answer this question is still a research question One view: testing is never done… the burden simply shifts from the developer to the customer Or: testing is done when you run out of time or money Or use a statistical model: Assume that errors decay logarithmically with testing time Measure the number of errors in a unit period Fit these measurements to a logarithmic curve Can then say: “with our experimentally valid statistical model we have done sufficient testing to say that with 95% confidence the probability of 1000 CPU hours of failure free operation is at least 0.995”

YAHOO!

Strategic Issues Issues for a successful software testing strategy: Specify product requirements long before testing commences For example: portability, maintainability, usability Do so in a manner that is unambiguous and quantifiable Understand the users of the software, with use cases Develop a testing plan that emphasizes “rapid cycle testing” Get quick feedback from a series of small incremental tests Build robust software that is designed to test itself Use assertions, exception handling and automated testing tools (Junit). Conduct formal technical reviews to assess test strategy and test cases - “Who watches the watchers?”

Testing Analysis and Design Syntactic correctness: Are UML and ADT notation used correctly? Semantic correctness: Does the model reflect the real world problem? Is UML used as intended by its designers? Is the ADT design complete (capturing all the classes and operations in UML diagram) and understandable? Testing for consistency: An inconsistent model has representations in one part that are not reflected in other portions of the model

Testing the Class Model Revisit the Use Cases, CRC cards and UML class model. Check that all collaborations are properly represented. Inspect the description of each CRC index card to make sure a delegated responsibility is part of the collaborator’s definition. Example: in a point of sale system. A read credit card responsibility of a credit sale class is accomplished if satisfied by a credit card collaborator Invert connections to ensure that each collaborator asked for a service is receiving requests from a reasonable source Example: a credit card being asked for a purchase amount Have you tested your analysis and design? If not, who will do it?

Testing OO Code Class tests Integration tests System Validation tests

[1] Class (Unit) Testing Smallest testable unit is the encapsulated class Test each operation as part of a class hierarchy because its class hierarchy defines its context of use Approach: Test each method (and constructor) within a class Test the state behavior (attributes) of the class between methods How is class testing different from conventional testing? Conventional testing focuses on input-process-output, whereas class testing focuses on each method, then designing sequences of methods to exercise states of a class But white-box testing can still be applied

Class Testing Process How to test? class to be tested results software engineer test cases Why a loop?

Class Test Case Design Identify each test case uniquely - Associate test case explicitly with the class and/or method to be tested State the purpose of the test Each test case should contain: A list of messages and operations that will be exercised as a consequence of the test A list of exceptions that may occur as the object is tested A list of external conditions for setup (i.e., changes in the environment external to the software that must exist in order to properly conduct the test) Supplementary information that will aid in understanding or implementing the test Automated unit testing tools facilitate these requirements

Challenges of Class Testing Encapsulation: Difficult to obtain a snapshot of a class without building extra methods which display the classes’ state Inheritance and polymorphism: Each new context of use (subclass) requires re-testing because a method may be implemented differently (polymorphism). Other unaltered methods within the subclass may use the redefined method and need to be tested White box tests: Basis path, condition, data flow and loop tests can all apply to individual methods, but don’t test interactions between methods

Random Class Testing Identify methods applicable to a class Define constraints on their use – e.g. the class must always be initialized first Identify a minimum test sequence – an operation sequence that defines the minimum life history of the class Generate a variety of random (but valid) test sequences – this exercises more complex class instance life histories Example: An account class in a banking application has open, setup, deposit, withdraw, balance, summarize and close methods The account must be opened first and closed on completion Open – setup – deposit – withdraw – close Open – setup – deposit –* [deposit | withdraw | balance | summarize] – withdraw – close. Generate random test sequences using this template

[2] Integration Testing OO does not have a hierarchical control structure so conventional top-down and bottom-up integration tests have little meaning Integration applied three different incremental strategies: Thread-based testing: integrates classes required to respond to one input or event Use-based testing: integrates classes required by one use case Cluster testing: integrates classes required to demonstrate one collaboration What integration testing strategies will you use?

Random Integration Testing Multiple Class Random Testing For each client class, use the list of class methods to generate a series of random test sequences. Methods will send messages to other server classes. For each message that is generated, determine the collaborating class and the corresponding method in the server object. For each method in the server object (that has been invoked by messages sent from the client object), determine the messages that it transmits For each of the messages, determine the next level of methods that are invoked and incorporate these into the test sequence

[3] Validation Testing Are we building the right product? Validation succeeds when software functions in a manner that can be reasonably expected by the customer. Focus on user-visible actions and user-recognizable outputs Details of class connections disappear at this level Apply: Use-case scenarios from the software requirements spec Black-box testing to create a deficiency list Acceptance tests through alpha (at developer’s site) and beta (at customer’s site) testing with actual customers How will you validate your term product?

Acceptance testing, anyone?

[4] System Testing Software may be part of a larger system. This often leads to “finger pointing” by other system dev teams Finger pointing defence: Design error-handling paths that test external information Conduct a series of tests that simulate bad data Record the results of tests to use as evidence Types of System Testing: Recovery testing: how well and quickly does the system recover from faults Security testing: verify that protection mechanisms built into the system will protect from unauthorized access (hackers, disgruntled employees, fraudsters) Stress testing: place abnormal load on the system Performance testing: investigate the run-time performance within the context of an integrated system

Can we do better?

Testing Summary Testing affects all stages of software engineering cycle One strategy is a bottom-up approach – class, integration, validation and system level testing XP advocates test-driven development: plan tests before you write any code, then test any changes Other techniques: white box (look into technical internal details) black box (view the external behaviour) debugging (systematic cause elimination approach is best) analysis design code test