testing object oriented software
play

Testing Object Oriented Software Chapter 15 p Learning objectives - PDF document

Testing Object Oriented Software Chapter 15 p Learning objectives Learning objectives Understand how obj ect orientation impacts Understand how obj ect orientation impacts software testing What characteristics matter? What


  1. Testing Object Oriented Software Chapter 15 p

  2. Learning objectives Learning objectives • Understand how obj ect orientation impacts • Understand how obj ect orientation impacts software testing – What characteristics matter? What characteristics matter? Why? Why? – What adaptations are needed? • Understand basic techniques to cope with each key • Understand basic techniques to cope with each key characteristic • Understand staging of unit and integration Understand staging of unit and integration testing for OO software (intra-class and inter- class testing) class testing) (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 2

  3. 15.2 Characteristics of OO Software Characteristics of OO Software Typical OO software characteristics that impact testing i • S tate dependent behavior • Encapsulation • Inheritance • Polymorphism and dynamic binding • Abstract and generic classes Abstract and generic classes • Exception handling (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 3

  4. Ch 15, slide 4 Quality activities and OO SW Quality activities and OO SW (c) 2008 Mauro Pezzè & Michal Young w Review

  5. OO definitions of unit and integration testing • Procedural software – unit = single program, function, or procedure it i l f ti d more often: a unit of work that may correspond to one or more intertwined functions or programs • Obj ect oriented software – unit = class or (small) cluster of strongly related classes (e.g., sets of Java classes that correspond to exceptions) ( g p p ) – unit testing = intra-class testing – integration testing = inter-class testing (cluster of classes) – dealing with single methods separately is usually too expensive (complex scaffolding), so methods are usually tested in the context of the class they belong to belong to (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 5

  6. 15.3 Orthogonal approach: Stages g pp g (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 6

  7. 15.4/5 Intraclass State Machine Testing Intraclass State Machine Testing • Basic idea: • Basic idea: – The state of an obj ect is modified by operations – Methods can be modeled as state transitions Methods can be modeled as state transitions – Test cases are sequences of method calls that traverse the state machine model traverse the state machine model • S tate machine model can be derived from specification (functional testing) code specification (functional testing), code (structural testing), or both [ Later: Inheritance and dynamic binding ] h i d d i bi di (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 7

  8. Informal state-full specifications Informal state-full specifications Slot : represents a slot of a computer model. Slot : represents a slot of a computer model. .... slots can be bound or unbound. Bound slots are assigned a compatible component, unbound slots are empty. Class slot offers the following services: Install : slots can be installed on a model as required or • optional optional . ... • Bind : slots can be bound to a compatible component. p p ... • Unbind : bound slots can be unbound by removing the b bound component. d t • IsBound : returns the current binding, if bound; otherwise returns the special value empty otherwise returns the special value empty . (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 8

  9. Identifying states and transitions Identifying states and transitions • From the informal specification we can identify • From the informal specification we can identify three states: – Not_installed Not installed – Unbound – Bound B d • and four transitions – install: from Not_installed to Unbound – bind: from Unbound to Bound – unbind: ...to Unbound – isBound: does not change state (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 9

  10. Deriving an FSM and test cases Deriving an FSM and test cases i B isBound d incorporate unBind 0 1 2 Not present Not present Unbound Unbound Bound Bound isBound bind unBind • TC-1: incorporate, isBound, bind, isBound • TC-2: incorporate, unBind, bind, unBind, isBound p , , , , (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 10

  11. Testing with State Diagrams Testing with State Diagrams • A statechart (called a “ state diagram” in UML) • A statechart (called a state diagram in UML) may be produced as part of a specification or design design • May also be implied by a set of message sequence charts (interaction diagrams), or other modeling formalisms ( g ), g • Two options: – Convert (“ flatten” ) into standard finite-state Convert ( flatten ) into standard finite state machine, then derive test cases – Use state diagram model directly g y (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 11

  12. Statecharts specification Statecharts specification class model method of super-state or class Model “OR t t ” “OR-state” called by class Model (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 12

  13. From Statecharts to FSMs From Statecharts to FSMs (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 13

  14. Statechart based criteria Statechart based criteria • In some cases “ flattening” a S • In some cases, flattening a S tatechart to a tatechart to a finite-state machine may cause “ state explosion” explosion • Particularly for super-states with “ history” • Alternative: Use the statechart directly • Alternative: Use the statechart directly • S imple transition coverage: execute all transitions of the original S t ll t iti f th i i l S t t tatechart h t • incomplete transition coverage of corresponding FS M • useful for complex statecharts and strong time constraints useful for complex statecharts and strong time constraints (combinatorial number of transitions) (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 14

  15. 15.6 Interclass Testing Interclass Testing • The first level of integration testing for obj ect • The first level of integration testing for obj ect- oriented software – Focus on interactions between classes Focus on interactions between classes • Bottom-up integration according to “ depends” relation l ti – A depends on B: Build and test B, then A • S tart from use/ include hierarchy – Implementation-level parallel to logical “ depends” relation • Class A makes method calls on class B Cl A k th d ll l B • Class A obj ects include references to class B methods – but only if reference means “ is part of” but only if reference means is part of (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 15

  16. Account Customer Order Package 1 1 0..* * 1 * * 1 * * USAccount OtherAccount CustomerCare LineItem JPAccount EUAccount UKAccount SimpleItem CompositeItem * * * * Model Model PriceList PriceList Component Component from a class * 1 1 * 0..1 * diagram diagram... Slot * 1 1 1 ModelDB SlotDB ComponentDB CSVdb (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 16

  17. ....to a hierarchy to a hierarchy Customer Order Package USAccount OtherAccount Component Component P i PriceList Li t CustomerCare Model JPAccount EUAccount UKAccount ComponentDB Slot Note: we may have Note: we may have M d lDB ModelDB SlotDB to break loops and generate stubs g (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 17

  18. Interactions in Interclass Tests Interactions in Interclass Tests • Proceed bottom-up • Consider all combinations of interactions – example: a test case for class Order includes a call to example: a test case for class Order includes a call to a method of class Model , and the called method calls a method of class S lot, exercise all possible relevant , p states of the different classes – problem: combinatorial explosion of cases – so select a subset of interactions: • arbitrary or random selection • plus all significant interaction scenarios that have been previously identified in design and analysis: sequence + collaboration diagrams g (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 18

  19. sequence diagram (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 19

  20. 15.7 Using Structural Information Using Structural Information • S • S tart with functional testing tart with functional testing – As for procedural software, the specification (formal or informal) is the first source of information for or informal) is the first source of information for testing obj ect-oriented software • “ S pecification” widely construed: Anything from a p y y g requirements document to a design model or detailed interface description • Then add information from the code (structural Th dd i f ti f th d ( t t l testing) – Design and implementation details not available from other sources (c) 2008 Mauro Pezzè & Michal Young Ch 15, slide 20

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend