a uml based testing approach
play

A UML-Based Testing Approach Using Sequence Diagrams, Statecharts, - PowerPoint PPT Presentation

A UML-Based Testing Approach Using Sequence Diagrams, Statecharts, and OCL Constraints Dehla Sokenou TU Berlin Softwaretechnik Overview of the Test System test data test generation driver test case abstract test data generation test


  1. A UML-Based Testing Approach Using Sequence Diagrams, Statecharts, and OCL Constraints Dehla Sokenou TU Berlin Softwaretechnik

  2. Overview of the Test System test data test generation driver test case abstract test data generation test cases UML test model execution test oracle executable test oracle test oracle (UML) test oracle preparation test oracle test integration verdict Dehla Sokenou - TU Berlin - Softwaretechnik 2 A UML-Based Testing Approach

  3. Agenda • motivation • UML-based testing • test case generation • test oracle • aspects used for testing • summary and outlook Dehla Sokenou - TU Berlin - Softwaretechnik 3 A UML-Based Testing Approach

  4. Motivation (1) • open issue: testing object-oriented systems • problems: lack of specification, test code integration • UML widely used for modeling and specifying object oriented systems • artifacts created in the analysis and design phases provide a good foundation for model-based testing • different views are modeled by using different diagram types  our idea: combining several diagram types for testing • test case selection based on UML diagrams • main information from sequence diagrams • additional information from state diagrams (UML statecharts) and OCL constraints Dehla Sokenou - TU Berlin - Softwaretechnik 4 A UML-Based Testing Approach

  5. Motivation (2) • test code integration often expensive • test code needs privileged access to the SUT • version control  our idea: using dynamic aspects for testing • code is integrated in non-invasive manner • aspects have privileged access to the adapted system Dehla Sokenou - TU Berlin - Softwaretechnik 5 A UML-Based Testing Approach

  6. Example: Bank Account protocol state machine Account status: int deposit balance: int open isActive(): boolean blocked isBlocked(): boolean activate block isClosed(): boolean getBalance(): int unblock activate() active block() close unblock() closed deposit close() withdraw deposit(amount: int) withdraw(amount: int) Dehla Sokenou - TU Berlin - Softwaretechnik 6 A UML-Based Testing Approach

  7. Protocol State Machines deposit • life cycle of objects open • call events blocked • no associated actions activate block • implicit preconditions unblock active • observer methods close closed deposit withdraw Dehla Sokenou - TU Berlin - Softwaretechnik 7 A UML-Based Testing Approach

  8. Test Case Generation  based on sequence diagrams and UML statecharts • sequence diagrams • typical message sequences • communication between objects • statecharts ( protocol state machines ) • life cycle of objects • each sequence diagram = 1 test case • additional information from statecharts • initialization of test sequences • (test oracle) Dehla Sokenou - TU Berlin - Softwaretechnik 8 A UML-Based Testing Approach

  9. Test Case Generation: Example deposit deposit open sd1 blocked blocked x:Bank a:Account b:Account activate block close unblock withdraw withdraw active active active close close close deposit deposit closed deposit deposit close close withdraw withdraw withdraw TF 1) x{new}; a{new}; a.activate; b{new}; b.activate; x.close TF 2) x{new}; a{new}; a.activate; b{new}; b.activate; b.block; x.close Dehla Sokenou - TU Berlin - Softwaretechnik 9 A UML-Based Testing Approach

  10. Test Oracle • statecharts • implicit pre and post conditions • valid states and transitions • OCL constraints • explicit pre and post conditions • 2 variants of combination 1. integration of OCL pre and post conditions into statecharts 2. derivation of pre and post conditions from statecharts and combination with explicit OCL constraints Dehla Sokenou - TU Berlin - Softwaretechnik 10 A UML-Based Testing Approach

  11. Test Oracle: Example (1) active withdraw deposit deposit open credit withdraw blocked activate block unblock active deposit close debit closed deposit deposit withdraw withdraw Dehla Sokenou - TU Berlin - Softwaretechnik 11 A UML-Based Testing Approach

  12. Test Oracle: Example (2) • protocol state machine • OCL: pre and post condition context active withdraw Account::withdraw(amount:int) deposit pre: true credit withdraw post: self.balance = self.balance@pre - amount deposit debit deposit withdraw Dehla Sokenou - TU Berlin - Softwaretechnik 12 A UML-Based Testing Approach

  13. Test Oracle: Example (3) • statechart: pre and post condition • OCL: pre and post condition context context Account::withdraw(amount:int) Account::withdraw(amount:int) pre: self.isActive and pre: true (self.balance >=0 or self.balance <0) post: self.balance = post: ((self.balance@pre >= 0 self.balance@pre - amount implies self.balance >= 0 or self.balance < 0) and (self.balance@pre < 0 implies self.balance < 0)) and self.isActive Dehla Sokenou - TU Berlin - Softwaretechnik 13 A UML-Based Testing Approach

  14. Test Oracle: Example (4) • statechart: derivation of pre and post condition active withdraw context Account::withdraw(amount:int) deposit state invariants pre: self.isActive and credit of source states withdraw (self.balance >=0 or self.balance <0) post: ((self.balance@pre >= 0 implies self.balance >= 0 or source deposit self.balance < 0) states debit target and states deposit (self.balance@pre < 0 withdraw implies self.balance < 0)) and self.isActive Dehla Sokenou - TU Berlin - Softwaretechnik 14 A UML-Based Testing Approach

  15. Test Oracle: Example (5) • resultant pre and post condition active context Account::withdraw(amount:int) withdraw deposit pre: true and self.isActive and … credit post: ((self.balance = withdraw OCL self.balance@pre - amount) and (self.balance@pre >= 0 deposit implies self.balance >= 0 or debit self.balance < 0) and deposit statechart (self.balance@pre < 0 withdraw implies self.balance < 0))) and self.isActive Dehla Sokenou - TU Berlin - Softwaretechnik 15 A UML-Based Testing Approach

  16. Test Code Integration (1) • integration of test oracles into the SUT • aspect-oriented language: Object Teams • generation of executable statecharts • compilation of OCL constraints • advantages • source and byte code of SUT not changed • aspects as roles with own state • tight coupling between aspect and role object • observer pattern already implemented (method calls are forwarded to aspect) • privileged access to the SUT Dehla Sokenou - TU Berlin - Softwaretechnik 16 A UML-Based Testing Approach

  17. Test Code Integration (2) • executable statechart with Object Teams • statechart as role of object under test • one team for each statechart level • dynamic aspect activation for statechart hierarchy implementation notify event calls object statechart under test check state • more teams for OCL constraints and logging Dehla Sokenou - TU Berlin - Softwaretechnik 17 A UML-Based Testing Approach

  18. Test Code Integration: Example team class Account_OCL { class Account_Role playedBy Account { Account obj_$AT_$PRE; abstract boolean isActive(); isActive -> isActive; /* CallOutBinding */  // also for clone and other query methods pre_withdraw <- before withdraw; /* CallInBinding */ post_withdraw <- after withdraw; void pre_withdraw(int amount) { /* Implementation */ obj_$AT_$PRE = clone(); if ( !pre ) { // test failed } } void post_withdraw(int amount) {  } } } Dehla Sokenou - TU Berlin - Softwaretechnik 18 A UML-Based Testing Approach

  19. Summary • combination of different diagram types • test case generation from sequences and statecharts • test oracle derivation from statecharts and OCL constraints • information collected from different views • independent test oracle • easy extension by using other diagram types • aspect-oriented integration of test oracle • non-invasive integration • privileged access Dehla Sokenou - TU Berlin - Softwaretechnik 19 A UML-Based Testing Approach

  20. Outlook • integration of additional UML diagram types • class diagram • activity diagram • additional OCL constraints (beside pre, post conditions, invariants) • derivation of test data from UML models • use of efficient techniques • e.g. DresdenOCL • industrial case study Dehla Sokenou - TU Berlin - Softwaretechnik 20 A UML-Based Testing Approach

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