Automated Object’s Statechart Generation and Testing from Class-Method Contracts Atul Gupta PhD Scholar, IIT Kapur, India.

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Advanced programming tools at Microsoft
Korat Automated Testing Based on Java Predicates Chandrasekhar Boyapati, Sarfraz Khurshid, Darko Marinov MIT ISSTA 2002 Rome, Italy.
Semantics Static semantics Dynamic semantics attribute grammars
1 Symbolic Execution for Model Checking and Testing Corina Păsăreanu (Kestrel) Joint work with Sarfraz Khurshid (MIT) and Willem Visser (RIACS)
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Software Testing and Quality Assurance
From Module Breakdown to Interface Specifications Completing the architectural design of Map Schematizer.
Software Testing and Quality Assurance
Describing Syntax and Semantics
Chapter 18 Testing Conventional Applications
1/23/2003University of Virginia1 Korat: Automated Testing Based on Java Predicates CS751 Presentation by Radu Stoleru C.Boyapaty, S.Khurshid, D.Marinov.
Korat: Automated Testing Based on Java Predicates Chandrasekhar Boyapati 1, Sarfraz Khurshid 2, and Darko Marinov 3 1 University of Michigan Ann Arbor.
Abstract data types What does ‘ abstract ’ mean? From Latin: to ‘ pull out ’— the essentials –To defer or hide the details –Abstraction emphasizes essentials.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Ranga Rodrigo. Class is central to object oriented programming.
Introduction to Software Testing Chapter 9.4 Model-Based Grammars Paul Ammann & Jeff Offutt
Object-Oriented Software Testing. C-S 5462 Object-Oriented Software Testing Research confirms that testing methods proposed for procedural approach are.
Abstract Data Types (ADTs) and data structures: terminology and definitions A type is a collection of values. For example, the boolean type consists of.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
From requirements to specification Specification is a refinement of requirements Can be included together as Software Requirements Specifications (SRS)
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Software Engineering Research paper presentation Ali Ahmad Formal Approaches to Software Testing Hierarchal GUI Test Case Generation Using Automated Planning.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
Software Testing Input Space Partition Testing. 2 Input Space Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
Logical view –show classes and objects Process view –models the executables Implementation view –Files, configuration and versions Deployment view –Physical.
CSC 480 Software Engineering Design by Contract. Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state.
First delivery of the course Software Quality and Testing Katerina Zdravkova, Anastas Mišev
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
Week 3: Requirement Analysis & specification
Protocols Software Engineering II Wirfs Brock et al, Designing Object-Oriented Software, Prentice Hall, Mitchell, R., and McKim, Design by Contract,
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
ISP RAS Java Specification Extension for Automated Test Development Igor B. Bourdonov, Alexei V. Demakov, Andrei A. Jarov, Alexander S. Kossatchev, Victor.
L13: Design by Contract Definition Reliability Correctness Pre- and post-condition Asserts and Exceptions Weak & Strong Conditions Class invariants Conditions.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Rigorous Testing by Merging Structural and Behavioral UML Representations Presented by Chin-Yi Tsai.
( = “unknown yet”) Our novel symbolic execution framework: - extends model checking to programs that have complex inputs with unbounded (very large) data.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Symstra: A Framework for Generating Object-Oriented Unit Tests using Symbolic Execution Tao Xie, Darko Marinov, Wolfram Schulte, and David Notkin University.
On Combining Multi-formalism Knowledge to Select Models for Model Transformation Testing Sagar Sen (1 st year PhD student), Benoit Baudry, Jean-Marie Mottu.
Component-Based Software Engineering Components and Interfaces Paul Krause and Sotiris Moschoyiannis.
From requirements to specification Specification is a refinement of requirements Can be included together as Software Requirements Specifications (SRS)
Cliquez pour modifier le style du titre Cliquez pour modifier les styles du texte du masque Deuxième niveau Troisième niveau Quatrième niveau Cinquième.
Testing Data Structures
Presentation of a paper on “Model-based Software Testing”
Automated Testing of Classes
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Input Space Partition Testing CS 4501 / 6501 Software Testing
Representation, Syntax, Paradigms, Types
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Specifications Liskov Chapter 9
State Machine Diagrams
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
Representation, Syntax, Paradigms, Types
CS310 Software Engineering Dr.Doaa Sami
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Representation, Syntax, Paradigms, Types
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
A Test Automation Language for Behavioral Models
Representation, Syntax, Paradigms, Types
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
A type is a collection of values
Presentation transcript:

Automated Object’s Statechart Generation and Testing from Class-Method Contracts Atul Gupta PhD Scholar, IIT Kapur, India

Organization  Motivation  Underlying Models  Automated Statechart Generation  V&V Using Statechart  Outcomes  Related Work  Conclusions

Organization  Motivation  Underlying Models  Automated Statechart Generation  V&V Using Statechart  Outcomes  Related Work  Conclusions

Motivation  Most development is maintenance.  Most specification is incremental.  Domain knowledge is important.  The connections between Structural and Behavior Specifications in OO Systems are weak Hence there is a need for tightly- coupled deigns for better evolution of software objects. Aim: Effective semi-automated V&V

Organization  Motivation  Underlying Models  Automated Statechart Generation  V&V Using Statechart  Outcomes  Related Work  Conclusions

Object Contracts: Constrained Class Diagram  A pre-condition to a method which is a restriction that must be true at the moment that the method is going to be executed.  A post-condition to an method which is a restriction that must be true at the moment that the method has just ended its execution.  An invariant which is a restriction that must be true before as well as after a method invocation. Specification Language: UML class diagram with OCL constraints

Notion of Object’s Abstract States  Object’s concrete states are infinite  Behavior typically depends on regions, defined by a set of ‘domain variables’ and their values.  Typically, these variables are part of object’s method contracts  Variables with abstracted-out values forms the state variables  A state is an specific assignment of these state variables

Example: A Bounded List  ‘size’ is the ‘domain variable’ which exhibit important behavior for the List  Five states corresponding to size 0 && size maxElement  Two invalid (Error) states and three valid states

Data Types: Abstract State Model  Numeric data types like integer, float, etc. are to be mapped to a finite set of disjoint partitions over its entire state space, e.g., an integer state variable X is mapped to three abstract states ‘X 0’.  Boolean and enumeration data types are considered inherently abstract.  Object references X are mapped either to the abstract state ‘X = null’, or to the abstract state ‘X isInstance Of C’ for each class C, of the object referenced by X.

Organization  Motivation  Underlying Models  Automated Statechart Generation  V&V Using Statechart  Outcomes  Related Work  Conclusions

Statechart Elements  Generated as a Directed Graph with States representing ‘nodes’ and method calls as ‘edges’ in the graph.  Edges may be associated with ‘conditions’.  If-statements in the method-conditions are represented by a ‘choice’ node in the graph  An start state modeled by a constructor of the class

Some Assumptions  Method contracts are available  Pre-conditions are in CNF  Numeric Variables appearing in method contracts but not the state variables, are specified with their range constraints. Search for all those object’s methods which may be invoked at a given state

Method invocation at a State

Obtaining Resulting States Post-conditions may be one of the following type  X  ( X is a Numeric state variable)  X rop (X is a Numeric state variable or an containing Numeric variables)  If then -else if … aMethod() [C1] [C2] A B C The is evaluated and the results are mapped to set of states

Organization  Motivation  Underlying Models  Automated Statechart Generation  V&V Using Statechart  Outcomes  Related Work  Conclusions

Effective V&V using statechart The resulting statechart can be inspected to find out discrepancies in the object behavior. E.g. - Incorrect transitions - Incorrect resulting states - Incorrect end-states - Un-reachable states  A correct statechart can be used for performing automated testing which includes - Method test sequence generation - test input generation - Generation of test-oracles

An Example: Class CoinBox Class CoinBox { int curQtr, quantity, totalQtrs boolean allowVend addQtr( ) // adding a quarter in the machine pre: quantity > 0; post : curQtr  +1 if (curQtr >= 2) then allowVend  TRUE retQtrs( ) // returning quarters back to the user pre: curQtr > 0; post : curQtr  0 allowVend  FALSE vend( ) // deliver a drink pre: allowVend = TRUE && quantity > 0; post : curQtr  0 allowVend  FALSE quantity  – 1 totalQtrs  + curQtr addDrink(m ) // add m unit of drink in the //machine pre: quantity = 0; post : quantity  + m

Automated Testing public class CoinBoxTest extends TestCase { CoinBox cbox; public CoinBoxTest(String name) { super(name); cbox = new CoinBox(); } public void testAddDrinkAtA(){ //testing addDrink(m) // in state A Try{ assertEquals(0, cbox.getCurrectQtrs()); assertFalse(cbox.isAllowVend()); assertEquals(0, cbox.getCurrectQty()); cbox.addDrink(2); assertEquals(0, cbox.getCurrectQtrs()); assertFalse(cbox.isAllowVend()); assertTrue(cbox.getCurrectQty()> 0) }catch (Exception e){fail(“Unwanted exception is raised”} } public void testaddQtrRaiseExceptionAtA(){ try{ assertEquals(0, cbox.getCurrectQtrs()); assertFalse(cbox.isAllowVend()); assertEquals(0, cbox.getCurrectQty()); cbox.addQtr(); fail(.Exception should be raised.) }catch (Exception e){} }

Organization  Motivation  Underlying Models  Automated Statechart Generation  V&V Using Statechart  Outcomes  Related Work  Conclusions

Discussions  The approach identifies various discrepancies like incomplete and inconsistent class specifications  A correct and consistent object statechart model is obtained from which reliable automated code and unit tests can easily be generated  It facilitates essential and effective verification for software re-use  The resulting statechart and class specifications are in a lock-steps which facilitates effective incremental development and change management  It allows a modeler to specify object's dynamic requirements declaratively on structural level, without the need to use full operational dynamic diagrams

Limitations  Variability in selecting ‘state variables’  All test-inputs may not be generated automatically  Limitations of symbolic execution

Related Work  Binder’s work on abstract state notion and state based testing  FSM generation from object/system specifications. [Grieskamp’02, Strooper’96]  Tao Xie et al Testing Framework ‘Symstra’  Work on Symbolic Execution  From scenarios to statecharts [Whittle’00]

Conclusions  The approach supports better software evolution (tightly-coupled modeling)  Performing effective V&V.  Nicely fit with ‘Design by Contract’ approach.  The model developed are human- comprehensible which can be further used for effective and efficient change management and requirements elicitation and validation.  Some case studies and proper evaluations are needed.