Mock Object Creation for Test Factoring

Slides:



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

Modular and Verified Automatic Program Repair Francesco Logozzo, Thomas Ball RiSE - Microsoft Research Redmond.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
A lightweight framework for testing database applications Joe Tang Eric Lo Hong Kong Polytechnic University.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Mahadevan Subramaniam and Bo Guo University of Nebraska at Omaha An Approach for Selecting Tests with Provable Guarantees.
Test-Driven Development and Refactoring CPSC 315 – Programming Studio.
Bug Isolation via Remote Program Sampling Ben Liblit, Alex Aiken, Alice X.Zheng, Michael I.Jordan Presented by: Xia Cheng.
Using Programmer-Written Compiler Extensions to Catch Security Holes Authors: Ken Ashcraft and Dawson Engler Presented by : Hong Chen CS590F 2/7/2007.
Efficient Systematic Testing for Dynamically Updatable Software Christopher M. Hayden, Eric A. Hardisty, Michael Hicks, Jeffrey S. Foster University of.
JUnit. What is unit testing? A unit is the smallest testable part of an application. A unit test automatically verifies the correctness of the unit. There.
Michael Ernst, page 1 Improving Test Suites via Operational Abstraction Michael Ernst MIT Lab for Computer Science Joint.
Leveraging User Interactions for In-Depth Testing of Web Applications Sean McAllister, Engin Kirda, and Christopher Kruegel RAID ’08 1 Seoyeon Kang November.
/* iComment: Bugs or Bad Comments? */
Regression testing Tor Stållhane. What is regression testing – 1 Regression testing is testing done to check that a system update does not re- introduce.
Automated Diagnosis of Software Configuration Errors
CS527: (Advanced) Topics in Software Engineering Overview of Software Quality Assurance Tao Xie ©D. Marinov, T. Xie.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Reverse Engineering State Machines by Interactive Grammar Inference Neil Walkinshaw, Kirill Bogdanov, Mike Holcombe, Sarah Salahuddin.
May08-21 Model-Based Software Development Kevin Korslund Daniel De Graaf Cory Kleinheksel Benjamin Miller Client – Rockwell Collins Faculty Advisor – Dr.
© 2012 IBM Corporation Rational Insight | Back to Basis Series Chao Zhang Unit Testing.
1 How to Apply Static and Dynamic Analysis in Practice © Software Quality Week ‘97 How to Apply Static and Dynamic Analysis in Practice - Otto Vinter Manager.
Model Based Conformance Testing for Extensible Internet Protocols Anastasia Tugaenko Scientific Adviser: Nikolay Pakulin, PhD.
T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University.
1. Validating Wireless Protocol Conformance Test Cases Amresh Nandan Paresh Jain June 2004.
Bug Localization with Machine Learning Techniques Wujie Zheng
Inferring Specifications to Detect Errors in Code Mana Taghdiri Presented by: Robert Seater MIT Computer Science & AI Lab.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
First BlueJ Day Houston, 2006 Unit Testing with BlueJ Bruce Quig Deakin University.
1 Test Selection for Result Inspection via Mining Predicate Rules Wujie Zheng
Combining Static and Dynamic Reasoning for Bug Detection Yannis Smaragdakis and Christoph Csallner Elnatan Reisner – April 17, 2008.
Error Explanation with Distance Metrics Authors: Alex Groce, Sagar Chaki, Daniel Kroening, and Ofer Strichman International Journal on Software Tools for.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
DevCOP: A Software Certificate Management System for Eclipse Mark Sherriff and Laurie Williams North Carolina State University ISSRE ’06 November 10, 2006.
Constraint Framework, page 1 Collaborative learning for security and repair in application communities MIT site visit April 10, 2007 Constraints approach.
Jeremy Nimmer, page 1 Automatic Generation of Program Specifications Jeremy Nimmer MIT Lab for Computer Science Joint work with.
1 © Agitar Software, 2007 Automated Unit Testing with AgitarOne Presented by Eamon McCormick Senior Solutions Consultant, Agitar Software Inc. Presented.
Modular Decomposition, Abstraction and Specifications
Continuous Testing in Eclipse
Optimistic Hybrid Analysis
Test Factoring: Focusing test suites on the task at hand
Chapter 8 – Software Testing
2016 Maintenance Innovation Challenge
Software engineering – 1
Mid-term Exam Account for 20% of the grade 100 points in total
Some Important Techniques For Regression Testing That You Must Know.
The Simplest Heuristics May Be The Best in Java JIT Compilers
EECS 582 Midterm Review Mosharaf Chowdhury EECS 582 – F16.
An experimental evaluation of continuous testing during development
High Coverage Detection of Input-Related Security Faults
Providing Secure Storage on the Internet
ACCELERATE DEVOPS WITH SERVICE VIRTUALIZATION
Test Case Purification for Improving Fault Localization
Automated Extraction of Inductive Invariants to Aid Model Checking
Coding Concepts (Basics)
Calpa: A Tool for Automating Dynamic Compilation
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Software Verification, Validation, and Acceptance Testing
Regression testing Tor Stållhane.
Introduction Previous work Test Suite Minimization
Please use speaker notes for additional information!
CS 240 – Advanced Programming Concepts
Software Testing COM /12/2019 Testing/Spring 98.
Case Study 1 By : Shweta Agarwal Nikhil Walecha Amit Goyal
Helping you make your code better
Test-Driven Ontology Development in Protégé
Designing For Testability
Recommending Adaptive Changes for Framework Evolution
Dynamic Binary Translators and Instrumenters
Presentation transcript:

Mock Object Creation for Test Factoring David Saff, Michael D. Ernst MIT CSAIL PASTE, 2004 June

Motivation Continuous testing plug-in for the Eclipse IDE* Test suite: Problem: find out about errors faster Solution: mock objects to replace Eclipse framework Set up Eclipse 30 secs 1 sec / plug-in test * Saff, Ernst, ETX 2004: Continuous testing in Eclipse

Outline Mock objects introduced Test factoring introduced Mock object creation for test factoring Conclusion

Outline Mock objects introduced Test factoring introduced Mock object creation for test factoring Conclusion

Unit test for plug-in Provided Checked Plug-in This is a call graph

System Test for plug-in Provided Checked Plug-in Eclipse This is a call graph

Unit Test with Mock Object Mock Objects replacing Eclipse Plug-in Provided Checked Part = enough to allow testing to proceed A mock object: provides part of the functionality of the original object(s) is focused on allowing the test to proceed

Mock objects for our example Using a debugger, determined: 147 static calls from plug-in to framework Defined on 49 classes 8 callbacks from framework to plug-in Substantial work to define mock objects. How well can we automate this process without additional manual effort?

Outline Mock objects introduced Test factoring introduced Mock object creation for test factoring Conclusion

What is a factored test? Split a system test into several smaller factored tests that exercise less code than system test can be added to the suite and prioritized Find out about errors faster embody assumptions about future code changes

Pros and cons of factored tests Pro: factored test should be faster if system test is slow requires an expensive resource or human interaction Pro: isolates bugs in subsystems Con: if assumptions about how developer will change the code are violated, can lead to: false negatives: OK, some delay false positives: bad, distract developer

Change language Change language: the set of tolerated changes db.insertRecord(“alice”, “617”); db.insertRecord(“bob”, “314”); db.insertRecord(“bob”, “314”); db.insertRecord(“alice”, “617”); Change method order? db.insertRecords( “alice: 617, bob: 314” ); Replace with equivalent call? When change language is violated, factored test must be discarded and re-created Can detect violation through analysis, or incorrect result.

A small catalog of test factorings Like refactorings, test factorings can be catalogued, reasoned about, and automated Separate Sequential Code: Also “Unroll Loop”, “Inline Method”, etc. to produce sequential code

A small catalog of test factorings Mocked Eclipse Plug-in Introduce Mock: Original test Mocked Plug-in Eclipse

Related work Early warning if assumptions hold Developer makes change Correct test results This work (static + dynamic) Produce factored tests Run factored tests Run original tests Binkley ’97 (static) Slice based on change Run factored tests

Outline Mock objects introduced Test factoring introduced Mock object creation for test factoring Conclusion

Basic Procedure: Trace Capture Tested Realm Params, Returns, Callbacks “Boundary” Mocked Realm MockExpectations

Basic Procedure: code generation MockExpectations encodes a state machine: MockExpectations DebugPlugin.getDefault() → [object id 347] 1 Better discussion of graphical language here No discussion here of how objects are ID’ed [object id 347].getLaunchManager() → [object id 78] 2 [object id 78].uniqueLaunchNameFrom(“a”) → “a134” 3

Expanding the change language Current tolerated change language includes: Extract method Inline method Using static analysis on mocked code, improve the procedure to include: Reorder calls to independent objects Add or remove calls to pure methods

Reorder calls to independent objects Group objects that share state into state sets One MockExpectations per state set: MockExpectations A MockExpectations B 1 2 3 1 2 3 MockExpectations C 1 2 3

Add or remove pure method calls Allow reordering, addition, removal of calls to pure methods: MockExpectations DebugPlugin.getDefault() → [object id 347] Accessors [object id 347].getLaunchManager() → [object id 78] [object id 78].uniqueLaunchNameFrom(“a”) → “a134” [object id 78].removeLaunch(“a134”) → NEXT STATE 1

Outline Mock objects introduced Test factoring introduced Mock object creation for test factoring Conclusion

Future work Develop a framework for test factoring Implement the “Implement Mock” factoring Analytic evaluation of framework Capture real-project change data* Measure notification time, false positives Case studies of test factoring in practice How do developers feel about the feedback they receive? * Saff, Ernst, ISSRE 2003: Reducing wasted development time via continuous testing

Conclusion Test factoring can indicate errors earlier “Introduce Mock” is an important test factoring for complicated systems We propose: Dynamic analysis for building mock objects Static analysis for increasing the change language Mail: saff@mit.edu

A small catalog of test factorings Separate Sequential Test: [graphic] Unroll Loop: Introduce Mock:

Frequent testing is good: Frequent manual testing in agile methodologies Frequent automatic testing in continuous testing. A testing framework should minimize the cost of frequent testing Suite completes rapidly First failing test completes rapidly

Getting faster to the first failing test Default: Test selection: Test prioritization: Test factoring: B1 B2 A1 A2 A3 A1 A2 A3 B2 A1 A2 A3 B1 B1’ B2’ A1’ A2’ A2 A3’ B2 A1 B1 …

Dynamic, change-independent test factoring Dynamic: instrument and run the original test Change-independent: factoring happens before any changes are made. Requires a hypothesized change language Binkley ’97: Static, change-dependent test factoring

Automatic test factoring: change-dependence Change-dependent test factoring: After tested code is changed, generate new tests with same result as old tests for that change. Change-independent test factoring: Before tested code is changed, generate new tests that have the same result as old tests for some set of changes. Better

Automatic test factoring: static vs. dynamic analysis Static analysis (Binkley ’97) Analyze code to determine mock object behavior Well-suited for change-dependent factoring May fail without source when dependent on file system or user interaction Guaranteed change language may be restrictive Dynamic analysis (this work) Instrument and run the original test, gather logs May run original test after factored test fails Can combine these