Random Test Generation of Unit Tests: Randoop Experience

Slides:



Advertisements
Similar presentations
Author: Carlos Pacheco, Shuvendu K. Lahiri, Michael D. Ernst, Thomas Ball MIT CSAIL.
Advertisements

J-Unit Framework.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
Objectives In this chapter you will: Learn what an exception is Learn how to handle exceptions within a program See how a try / catch block is used to.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 16: Exception Handling.
Feedback-Directed Random Test Generation Automatic Testing & Validation CSI5118 By Wan Bo.
Testing & Debugging CSC 171 FALL 2004 LECTURE 13.
Hybrid Concolic Testing Rupak Majumdar Koushik Sen UC Los Angeles UC Berkeley.
Michael Ernst, page 1 Improving Test Suites via Operational Abstraction Michael Ernst MIT Lab for Computer Science Joint.
Writing a Unit test Using JUnit At the top of the file include: import junit.framework.TestCase; The main class of the file must be: public Must extend.
1 Advanced Material The following slides contain advanced material and are optional.
Chair of Software Engineering Automatic Verification of Computer Programs.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
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.
State coverage: an empirical analysis based on a user study Dries Vanoverberghe, Emma Eyckmans, and Frank Piessens.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Finding Errors in.NET with Feedback-Directed Random Testing Carlos Pacheco (MIT) Shuvendu Lahiri (Microsoft) Thomas Ball (Microsoft) July 22, 2008.
Feed Back Directed Random Test Generation Carlos Pacheco1, Shuvendu K. Lahiri2, Michael D. Ernst1, and Thomas Ball2 1MIT CSAIL, 2Microsoft Research Presented.
I. Pribela, M. Ivanović Neum, Content Automated assessment Testovid system Test generator Module generators Conclusion.
AMOST Experimental Comparison of Code-Based and Model-Based Test Prioritization Bogdan Korel Computer Science Department Illinois Institute of Technology.
CUTE: A Concolic Unit Testing Engine for C Technical Report Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Practical Semantic Test Simplification Sai Zhang University of Washington.
Software Engineering 2003 Jyrki Nummenmaa 1 CASE Tools CASE = Computer-Aided Software Engineering A set of tools to (optimally) assist in each.
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Bug Localization with Machine Learning Techniques Wujie Zheng
Test Suite Reduction for Regression Testing of Simple Interactions between Two Software Modules Dmitry Kichigin.
Software Engineering Research paper presentation Ali Ahmad Formal Approaches to Software Testing Hierarchal GUI Test Case Generation Using Automated Planning.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 6: Exhaustive Bounded Testing and Feedback-Directed Random Testing.
What is Genetic Programming? Genetic programming is a model of programming which uses the ideas (and some of the terminology) of biological evolution to.
Tao Xie North Carolina State University Nikolai Tillmann, Peli de Halleux, Wolfram Schulte Microsoft Research.
Code Contracts Parameterized Unit Tests Tao Xie. Example Unit Test Case = ? Outputs Expected Outputs Program + Test inputs Test Oracles 2 void addTest()
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
1 Test Selection for Result Inspection via Mining Predicate Rules Wujie Zheng
Xusheng Xiao North Carolina State University CSC 720 Project Presentation 1.
Feedback-directed Random Test Generation Carlos Pacheco Shuvendu Lahiri Michael Ernst Thomas Ball MIT Microsoft Research January 19, 2007.
Finding Errors in.NET with Feedback-Directed Random Testing Carlos Pacheco (MIT) Shuvendu Lahiri (Microsoft) Thomas Ball (Microsoft) July 22, 2008.
Directed Random Testing Evaluation. FDRT evaluation: high-level – Evaluate coverage and error-detection ability large, real, and stable libraries tot.
Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop.
Bug Localization with Association Rule Mining Wujie Zheng
1 Exposing Behavioral Differences in Cross-Language API Mapping Relations Hao Zhong Suresh Thummalapenta Tao Xie Institute of Software, CAS, China IBM.
Benchmarking Effectiveness for Object-Oriented Unit Testing Anthony J H Simons and Christopher D Thomson.
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
32nd International Conference on Very Large Data Bases September , 2006 Seoul, Korea Efficient Detection of Empty Result Queries Gang Luo IBM T.J.
November 27, 2007 Verification of a Concurrent Priority Queue Bart Verzijlenberg.
Automated Test Generation CS Outline Previously: Random testing (Fuzzing) – Security, mobile apps, concurrency Systematic testing: Korat – Linked.
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
( = “unknown yet”) Our novel symbolic execution framework: - extends model checking to programs that have complex inputs with unbounded (very large) data.
Unit Testing with FlexUnit
Local Search Algorithms and Optimization Problems
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
CS527 Topics in Software Engineering (Software Testing and Analysis) Darko Marinov September 7, 2010.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Symstra: A Framework for Generating Object-Oriented Unit Tests using Symbolic Execution Tao Xie, Darko Marinov, Wolfram Schulte, and David Notkin University.
Automatic Diagnosis and Response to Memory Corruption Vulnerabilities Authors: Jun Xu, Peng Ning, Chongkyung Kil, Yan Zhai, Chris Bookholt Cyber Defense.
Shadow Shadow of a Doubt: Testing for Divergences Between Software Versions Hristina PalikarevaTomasz KuchtaCristian Cadar ICSE’16, 20 th May 2016 This.
SWE 434 SOFTWARE TESTING AND VALIDATION LAB2 – INTRODUCTION TO JUNIT 1 SWE 434 Lab.
Introduction to Algorithms
Presented by Mahadevan Vasudevan + Microsoft , *UC-Berkeley
Eclat: Automatic Generation and Classification of Test Inputs
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Random Unit-Test Generation with MUT-aware
Introduction to Data Structures
JUnit Reading: various web pages
CUTE: A Concolic Unit Testing Engine for C
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
CSE 1020:Software Development
Lab 8: GUI testing Software Testing LTAT
Unit Testing.
Presentation transcript:

Random Test Generation of Unit Tests: Randoop Experience Wujie Zheng wjzheng@cse.cuhk.edu.hk

Outline Automated Test Generation of Unit Tests Randoop: Feedback-directed Random Test Generation Randoop Experience Potential Improvements

Outline Automated Test Generation of Unit Tests Randoop: Feedback-directed Random Test Generation Randoop Experience Potential Improvements

Automated Test Generation of Unit Tests Problem Given a method of a class, how to automatically generate test cases to execute most of its code, i.e., to achieve high code coverage.

Automated Test Generation of Unit Tests A simple example class under test: java.util.Stack method under test: public synchronized int search(Object o) { int i = lastIndexOf(o); if (i >= 0) { return size() - i; } return -1;

Automated Test Generation of Unit Tests What need to be generated? Test Inputs not only primitive values but also objects, including the receiver object Test Oracles Could use some basic contracts For not much test inputs, manually added by testers

Automated Test Generation of Unit Tests An example test case // a test case for Stack.search(Object) // existing (previous generated) sequences that create parameters Stack var0 = new Stack(); String var1 = "hi!"; var0.push((Object)var1); // the method under test int var2 = var0.search(var1); // test oracles assertTrue(var0.equals(var0)); assertTrue(var2==1); // Regression assertion

Automated Test Generation of Unit Tests Main solutions Random Approaches Randomly create and mutate objects For a method under test, select objects created in existing sequences as its parameters Simple, scalable, but may not efficient Systematic Approaches Explore the possible paths systematically, for each path, collect the path condition and solve it to generate test inputs Potential high coverage, but complex Systematic approaches Build a connection between inputs and program paths Rely on constraint solvers: good for primitive values, but may not easy for objects

Outline Automated Test Generation of Unit Tests Randoop: Feedback-directed Random Test Generation Randoop Experience Potential Improvements

Randoop: Feedback-directed Random Test Generation The basic idea Undirected random test generation is not efficient because it does not prune redundant or error objects (generated by duplicate or different method sequences) Identify redundant or error objects early can prune large search space

Randoop: Feedback-directed Random Test Generation The basic idea Identify redundant objects Use the equals() method Identify error objects Exceptions. Exceptions frequently correspond to precondition violations for a method, and therefore there is little point extending them Null Null dereference exceptions caused by using null as an argument are often uninteresting Set the redundant or error objects as not extensible

Randoop: Feedback-directed Random Test Generation Sequence generation for a method To execute a method m(T1,…,Tk), we need to find existing sequences that generate the parameters For each Ti Primitive type, randomly select a value from a pool Reference type, select a extensible (non-redundant and legal) value v from existing sequences, or use null Generate a new sequence, including the method m and the required sequences to generate the parameters

Randoop: Feedback-directed Random Test Generation The Randoop algorithm Repeat until timeout Randomly select a method m(T1,…,Tk) Generate a new sequence for m Execute the new sequence Check simple oracles, set the extensible flags of the objects Output the generated sequences as unit tests

Outline Automated Test Generation of Unit Tests Randoop: Feedback-directed Random Test Generation Randoop Experience Potential Improvements

Randoop Experience Subject programs Interested Metrics Java.util Berkeley DB Interested Metrics Number of tests Code coverage Error detection

Randoop Experience Experiments on Java.util Demo 7 classes in Java.util, used in other researchers’ experiments Run Randoop 60 seconds 4834 tests 50.8% instruction coverage 195 failed tests, many false positives! Demo

Randoop Experience Experiments on Berkeley DB Demo Java edition of Berkeley DB, com.sleepycat.je Run Randoop 60 seconds Around 20,000 tests 30% instruction coverage 300 failed tests, many false positives! Need to prepare some environments, e.g., files in the disk Can more tests achieve higher coverage? Run Randoop 120 seconds: out of memory Demo

Outline Automated Test Generation of Unit Tests Randoop: Feedback-directed Random Test Generation Randoop Experience Potential Improvements

Potential Improvements The problems of Randoop Not enough code coverage Difficult to generate interesting sequences quickly before running out of memory Too large test suites Need to perform test selection (reduction)

Thank you!