Applications of Metamorphic Testing Chris Murphy University of Pennsylvania November 17, 2011.

Slides:



Advertisements
Similar presentations
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Advertisements

CS527: Advanced Topics in Software Engineering (Software Testing and Analysis) Darko Marinov September 18, 2008.
Testing Concurrent/Distributed Systems Review of Final CEN 5076 Class 14 – 12/05.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Data Abstraction II SWE 619 Software Construction Last Modified, Spring 2009 Paul Ammann.
Certification of Computational Results Greg Bronevetsky.
Theoretical Program Checking Greg Bronevetsky. Background The field of Program Checking is about 13 years old. Pioneered by Manuel Blum, Hal Wasserman,
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION TESTING II Autumn 2011.
Today’s Agenda  HW #1 Due  Quick Review  Finish Input Space Partitioning  Combinatorial Testing Software Testing and Maintenance 1.
1 Software Testing and Quality Assurance Lecture 9 - Software Testing Techniques.
Metamorphic Testing Techniques to Detect Defects in Applications without Test Oracles Christian Murphy Thesis Defense April 12, 2010.
1 Application of Metamorphic Testing to Supervised Classifiers Xiaoyuan Xie, Tsong Yueh Chen Swinburne University of Technology Christian Murphy, Gail.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Properties of Machine Learning Applications for Use in Metamorphic Testing Chris Murphy, Gail Kaiser, Lifeng Hu, Leon Wu Columbia University.
Automatic System Testing of Programs without Test Oracles
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
(c) 2007 Mauro Pezzè & Michal Young Ch 16, slide 1 Fault-Based Testing.
CSE 830: Design and Theory of Algorithms
The Specification-Consistent Coordination Model (SCCM) and its applications to Byzantine Failures.
On Effective Testing of Health Care Simulation Software Christian Murphy, M.S. Raunak, Andrew King, Sanjian Chen, Christopher Imbriano, Gail Kaiser, Insup.
Using JML Runtime Assertion Checking to Automate Metamorphic Testing in Applications without Test Oracles Christian Murphy, Kuang Shen, Gail Kaiser Columbia.
Lecture 3 Aug 31, 2011 Goals: Chapter 2 (algorithm analysis) Examples: Selection sorting rules for algorithm analysis discussion of lab – permutation generation.
Parameterizing Random Test Data According to Equivalence Classes Chris Murphy, Gail Kaiser, Marta Arias Columbia University.
AP Computer Science.  Not necessary but good programming practice in Java  When you override a super class method notation.
EE694v-Verification-Lect5-1- Lecture 5 - Verification Tools Automation improves the efficiency and reliability of the verification process Some tools,
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
Using Runtime Testing to Detect Defects in Applications without Test Oracles Chris Murphy Columbia University November 10, 2008.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 9 Functional Testing
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Introduction 01_intro.ppt
Chapter 1 Algorithm Analysis
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Simulation II IE 2030 Lecture 18. Outline: Simulation II Advanced simulation demo Review of concepts from Simulation I How to perform a simulation –concepts:
Composition of Functions Suppose we have two money machines, both of which increase any money inserted into them. Machine A doubles our money while Machine.
Verification and Validation Overview References: Shach, Object Oriented and Classical Software Engineering Pressman, Software Engineering: a Practitioner’s.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
CS717 Algorithm-Based Fault Tolerance Matrix Multiplication Greg Bronevetsky.
1 Test Selection for Result Inspection via Mining Predicate Rules Wujie Zheng
Software Testing and Quality Assurance Practical Considerations (4) 1.
Xusheng Xiao North Carolina State University CSC 720 Project Presentation 1.
“Isolating Failure Causes through Test Case Generation “ Jeremias Rößler Gordon Fraser Andreas Zeller Alessandro Orso Presented by John-Paul Ore.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
Experimentation in Computer Science (Part 2). Experimentation in Software Engineering --- Outline  Empirical Strategies  Measurement  Experiment Process.
2.1 Functions. Functions in Mathematics f x y z f (x, y, z) Domain Range.
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
Week 5-6 MondayTuesdayWednesdayThursdayFriday Testing III No reading Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Mutation Testing Breaking the application to test it.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
Building Java Programs Chapter 13 Lecture 13-1: binary search and complexity reading:
CS 5150 Software Engineering Lecture 21 Reliability 2.
Cs498dm Software Testing Darko Marinov January 24, 2012.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
A Review of Software Testing - P. David Coward
Software Testing.
Testing Tutorial 7.
CS223: Software Engineering
John D. McGregor Session 9 Testing Vocabulary
Verification and Testing
Verification and Validation Overview
John D. McGregor Session 9 Testing Vocabulary
John D. McGregor Session 9 Testing Vocabulary
Software testing strategies 2
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Algorithms and Problem Solving
CSE 1020:Software Development
Presentation transcript:

Applications of Metamorphic Testing Chris Murphy University of Pennsylvania November 17, 2011

About Me Lecturer, University of Pennsylvania PhD-Computer Science, Columbia Univ, 2010 Advisor: Prof. Gail Kaiser Research: software testing, CS education Seven years experience in software development industry

Problem: When testing a piece of software, how can we know that we’ve created enough test cases?

Problem: When testing a piece of software, how can we create more test cases? Solution: We use properties of the software to create new test cases from existing ones (particularly those that have not failed). Result: This approach, known as metamorphic testing, is more effective at testing certain types of software than other approaches.

Today's Talk What is metamorphic testing? How is metamorphic testing used to find bugs in software? How can metamorphic testing be applied to applications that do not have test oracles? What are the open research questions related to metamorphic testing?

UPenn CIS 573 Software Engineering Graduate-level software engineering course Just over 100 students Focuses on software maintenance issues: – Testing – Formal verification – Debugging – Fault Localization – Refactoring

It's your first day of work as a software engineer at BloobleSoft. Your boss gives you 6,000 lines of code and a specification and says “find the bugs”. Where would you start?

Specification Code Test Case Generation Strategy Test Cases Test Cases Test Cases Test Cases

You've created 4,837 test cases. All of them pass. How do you know when you're done creating test cases?

Testing Requirements Test Cases Desired Adequacy Level Measurable Adequacy Criteria Acceptable? Coverage Level

Your test cases are achieving 100% coverage. None of them have found any bugs. Are those test cases useful?

Maybe those test cases can be used to create new test cases. The more test cases, the better. Right? This is the idea behind “metamorphic testing”. [Chen et al., HKUST TR CS-98-01, 1998]

A (really, really, really, really) simple example

Let's say you're testing a cosine function. (I know, I know...) How could we use this test case to create new test cases? You have a test case {45º, }, i.e. cos(45º) =

We know that the cosine function exhibits certain properties. That is, if we make certain changes to the input, we can predict the effect on the output. These are referred to as “metamorphic properties”.

What are the metamorphic properties of the cosine function? cos(x + 360º) = cos(x) cos(x + 180º) = -1 * cos(x) cos(x - 360º) = cos(x) That is, if we add 360 to the input, the output should not change.

Given our original test case {45°, }, we can create three follow-on test cases. Property: cos(x + 360º) = cos(x) Input: 45º + 360º = 405º Output: cos(45º) = Property: cos(x - 360º) = cos(x) Input: 45º - 360º = -315º Output: cos(45º) = Property: cos(-1 * x) = -1 * cos(x) Input: -1 * 45º = -45º Output: -1 * cos(45º) =

x f f(x) Initial test case {x, f(x)} t(x) f f(t(x)) Follow-on test case {t(x), f(t(x))} t A metamorphic property of a function f is a pair of functions (t, g) such that f(t(x)) = g(f(x)) for all inputs x g(f(x)) g =

but wait, isn’t that the same as…

Program invariants: -1 ≤ cos(x) ≤ 1 Algebraic properties: cos²(x) = 1 – sin²(x) Describe legal ranges/values of a function, but not how it should react when the input is changed. Describe the relationships between multiple functions, but not a single function.

simple categories of properties

abcdef Initial test case cebafd Permute 2a2b2c2d2e2f Multiply s sum s Add a+2b+2c+2d+2e+2f+2 s+12 2s sum s+g abcdef Include gabcde Exclude s-f sum

abcdef Initial test case #1 s sum ghijkl Initial test case #2 t sum Compose s+t sum abcdef ghijkl Combination of properties 2s+2t sum 2h2d2a2k2e2g 2i2c2l2f2b2j

Common Metamorphic Properties Additive: Increase (or decrease) numerical values by a constant Multiplicative: Multiply numerical values by a constant Permutative: Randomly permute the order of elements in a set Invertive: Create the “opposite” of a set Inclusive: Add a new element to a set Exclusive: Remove an element from a set Compositional: Compose a set [Murphy et al., SEKE’08]

Other Types of Properties Noise-based: include input values that will not affect the output Semantically Equivalent: create inputs that are have the same “meaning” as the original Heuristic: create inputs that are “close” to the original Statistical: create inputs that exhibit the same statistical properties

one more example

Consider a function that takes a set of Points (x-y coordinates) and calculates the total distance from the first to the last, via the rest. What are that function’s metamorphic properties?

Okay, I think I get it. But does it really work?!?!

In order to find bugs… But how can this be?!?! 1. The original test case must pass, even though there is a bug. 2. The follow-on test case must fail.

/* Return the smallest value in the array */ int findMin(int A[]) { int min = A[0]; for (int i = 1; i < A.length-1; i++) { if (A[i] < min) min = A[i]; } return min; }

/* Return the smallest value in the array */ int findMin(int A[]) { int min = A[0]; for (int i = 1; i < A.length-1; i++) { if (A[i] < min) min = A[i]; } return min; } Test case { {2, 1, 4, 3}, 1}PASS! 100% statement coverage! 100% branch coverage!

/* Return the smallest value in the array */ int findMin(int A[]) { int min = A[0]; for (int i = 1; i < A.length-1; i++) { if (A[i] < min) min = A[i]; } return min; } Test case { {2, 1, 4, 3}, 1} Metamorphic property: If we permute the input, the output remains the same. Follow-on test case: { {4, 2, 3, 1}, 1}FAIL!

metamorphic testing in the real world

Bioinformatics [Chen et al., BMC Bioinf., 2009] Machine Learning [Xie et al., JSS, 2011] Network Simulation [Chen et al., FTDS, 2009] Computer Graphics [Guderlei et al., QSIC, 2007]

what types of applications is metamorphic testing good for?

Applications that deal primarily with numerical input and numerical output. Applications that do not have test oracles. Applications that use graph-based algorithms. Compilers. [Zhou et al., ISFST’04]

Specification Program Test Input Actual Output Expected Output Oracle

what if there is no oracle?

Machine Learning

Discrete Event Simulation

x f f(x) t(x) f f(t(x)) Actual t If f(t(x)) = g(f(x)) that does not mean that the output is correct. g =? But if f(t(x)) != g(f(x)) then one (or both) must be incorrect. g(f(x)) Expected

example: RapidMiner

RapidMiner is a suite of machine learning algorithms implemented in Java. That is: c = Classify(M(T), e) In its NaïveBayes implementation, a confidence level c is reported whenever it classifies an example e using a model M created from a training data set T.

We expect that if we modify T to include an extra instance of e, then the confidence level should double, since we are twice as certain about the classification. That is: Classify(M(T+e), e) = 2 * Classify(M(T), e) Our testing detected violations of this property, thus revealing a bug. [Murphy et al., ICST’09]

empirical study

Goal: Show that metamorphic testing is more effective than other techniques at finding bugs in applications without test oracles. Approach: Use mutation analysis to insert faults into the applications, and see how many are detected using various techniques.

Application domains investigated: 1. Machine Learning (C4.5, MartiRank, Support Vector Machines, PAYL) 2. Discrete Event Simulation (JSim) 3. Information Retrieval (Lucene) 4. Optimization (gaffitter)

Techniques investigated: 1. Metamorphic Testing 2. Runtime Assertion Checking 3. Partial Oracle

Experimental Results [Murphy et al., ISSTA’09]

can we do better?

That experiment used application- level metamorphic properties. What if we test at the function level, too? This is known as Metamorphic Runtime Checking. [Murphy et al., TR CUCS , 2009] And continuously conduct those tests while the software is running?

Experimental Results

research directions

When I run my test, I see that the metamorphic property is violated. Does that mean there's a bug? How can we know whether the metamorphic properties are sound? Well, not necessarily....

I've used the guidelines to identify as many metamorphic properties as I could. Does that mean that's all of them? How can we know whether the set of metamorphic properties is complete? Well, not necessarily....

I've used the guidelines to identify as many metamorphic properties as I could. Does that mean that's all of them? Could we detect (likely) metamorphic properties automatically? Well, not necessarily....

I have a function for which I expect that, if I double the input, the output should be doubled. Could I verify that property without actually executing the code? Can metamorphic properties be verified statically? Well, probably....

summary

Metamorphic testing is a method of creating new test cases from existing ones. It depends heavily on the software’s metamorphic properties, which are often numerical. Metamorphic testing is particularly effective at finding bugs in applications that do not have test oracles.

thanks!

Applications of Metamorphic Testing Chris Murphy University of Pennsylvania