Tao Xie ( [email protected] ) Advisor: David Notkin Department of Computer Science &...

1
Tao Xie ([email protected] ) Advisor: David Notkin Department of Computer Science & Engineering, University of Washington, Seattle Syntactically identical to axioms in algebraic specifications Associated with counts of satisfying and violating instances • 79 common tests and 29 special tests (8 tests are both common and special) identified out of 6777 automatically generated tests. • 43 universal properties and 45 common properties. Solution Solution Results for Results for java.util.LinkedList java.util.LinkedList Automatic Identification of Common and Special Object-Oriented Unit Tests Related Work Related Work Ernst et al., Dynamically Discovering Likely Program Invariants to Support Program Evolution, IEEE Trans. Softw. Eng, 01. Henkel & Diwan, Discovering Algebraic Specifications from Java Classes, ECOOP 03. Xie et al., Rostra: A Framework for Detecting Redundant Object-Oriented Some Examples of Common/Special Some Examples of Common/Special Tests Tests Programmers often overlook some special or even common tests Automatic test generation tools produce a large number of tests How to automatically identify special tests and common tests from them? Problem Problem Automatically identify common and special tests without requiring specifications Based on dynamically inferred Statistical Algebraic Abstractions Test generati on Common or universal propertie s Java class bytecode Method-call composition Statist ical inferen ce Abstracti on templates Test identification Special tests Common tests Common test a satisfying instance of a universal property or common property Special test a violating instance of a common property *. Common prop: remove(removeLast(S).state, m0_2).state == removeLast(remove(S, m0_2).state).state Satisfying count: 318 (common test) LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.removeLast( ); m.remove(new Integer(-1)); Violating count: 42 (special test) LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.add (0, new Integer(0)); m.removeLast( ); m.remove(new Integer(-1)); size(clear(S).state).retval == 0 Satisfying count: 121 Violating count: 0 remove(add(S, m0_1).state, m0_2).state == add(remove(S, m0_2).state, m0_1).state Satisfying count: 315 Violating count: 45 java.util.LinkedList as the illustrative example 25 pub methods and more than 300 class bytecode • Generate representative method arguments • Iteratively invoke different arguments on each non- equivalent receiver- object (e.g. five iterations) [Xie et al. 04] clear S1 size S2 == S3 S4 g(f(S, args1).state, args2).retval == const g(f(S, args1).state, args2).state == f(g(S, args1).state, args2).state Universal property: all instances are satisfying instances. Common property: instances are mostly (e.g. 80%) satisfying instances • Statistical algebraic abstractions are not required to be universally true during test executions, different from properties inferred by previous approaches [Ernst et al. 01, Henkel & Diwan References References *. Common prop: remove(removeFirst(S).state, m0_2).retval == remove(S, m0_2).retval Satisfying count: 315 (common test) LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.removeFirst ( ); m.remove(new Integer(1)); Violating count: 45 (special test) LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.removeFirst ( ); m.remove(new Integer(-1)); *. Conditional universal prop: lastIndexOf(addFirst(S, m0_1).state, m0_2).retval == (lastIndexOf(S, m0_2).retval + 1) [where (m0_1==m0_2)] Satisfying count: 120 (special test) LinkedList m = new LinkedList( ); m.addFirst(new Integer(-1)); m.lastIndexOf(new Integer(- 1)); *. Common prop: removeLast(addFirst(S, m0_1).state).state == addFirst(removeLast(S).state, m0_1).state Satisfying count: 117 (common test) LinkedList m = new LinkedList( ); m.add(0, new Integer(-1)); m.addFirst(new Integer(0)); m.removeLast ( ); Violating count: 3 (special test) LinkedList m = new LinkedList( ); m.addFirst(new Integer(0)); m.removeLast ( ); http://www.cs.washington.edu/homes/taoxie/ sabicu/

Transcript of Tao Xie ( [email protected] ) Advisor: David Notkin Department of Computer Science &...

Page 1: Tao Xie ( taoxie@cs.washington.edu ) Advisor: David Notkin Department of Computer Science & Engineering, University of Washington, Seattle Syntactically.

Tao Xie ([email protected]) Advisor: David NotkinDepartment of Computer Science & Engineering, University of Washington, Seattle

• Syntactically identical to axioms in algebraic specifications

• Associated with counts of satisfying and violating instances

• 79 common tests and 29 special tests (8 tests are both common and special) identified out of 6777 automatically generated tests.

• 43 universal properties and 45 common properties.

SolutionSolution

Results for java.util.LinkedListResults for java.util.LinkedList

Automatic Identification of Common and Special Object-Oriented Unit TestsAutomatic Identification of Common and Special Object-Oriented Unit Tests

Related WorkRelated Work• Ernst et al., Dynamically Discovering Likely Program

Invariants to Support Program Evolution, IEEE Trans. Softw. Eng, 01.

• Henkel & Diwan, Discovering Algebraic Specifications from Java Classes, ECOOP 03.

• Xie et al., Rostra: A Framework for Detecting Redundant Object-Oriented Unit Tests, ASE 04.

Some Examples of Common/Special TestsSome Examples of Common/Special Tests

• Programmers often overlook some special or even common tests

• Automatic test generation tools produce a large number of tests

• How to automatically identify special tests and common tests from them?

ProblemProblem

• Automatically identify common and special tests without requiring specifications

• Based on dynamically inferred Statistical Algebraic Abstractions

Test generation

Common oruniversal properties

Java class bytecode Method-call

compositionStatisticalinference

Abstractiontemplates

Testidentification

Specialtests

Commontests

• Common test a satisfying instance of a universal property or common property

• Special test a violating instance of a common property

*. Common prop: remove(removeLast(S).state, m0_2).state == removeLast(remove(S, m0_2).state).stateSatisfying count: 318 (common test)

LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.removeLast( ); m.remove(new Integer(-1));Violating count: 42 (special test) LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.add (0, new Integer(0)); m.removeLast( ); m.remove(new Integer(-1));

size(clear(S).state).retval == 0

Satisfying count: 121 Violating count: 0

remove(add(S, m0_1).state, m0_2).state

== add(remove(S, m0_2).state, m0_1).state Satisfying count: 315 Violating count: 45

java.util.LinkedList as the illustrative example 25 pub methods and more than 300 LOC

class bytecode

• Generate representative method arguments

• Iteratively invoke different arguments on each non-equivalent receiver-object(e.g. five iterations)

[Xie et al. 04]

clear

S1

size

S2 == S3

S4

g(f(S, args1).state, args2).retval == constg(f(S, args1).state, args2).state == f(g(S, args1).state, args2).state

• Universal property: all instances are satisfying instances.

• Common property: instances are mostly (e.g. 80%) satisfying instances

• Statistical algebraic abstractions are not required to be universally true during test executions, different from properties inferred by previous approaches

[Ernst et al. 01, Henkel & Diwan 03].

ReferencesReferences

*. Common prop: remove(removeFirst(S).state, m0_2).retval == remove(S, m0_2).retval

Satisfying count: 315 (common test) LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.removeFirst ( ); m.remove(new Integer(1));Violating count: 45 (special test) LinkedList m = new LinkedList( ); m.add (0, new Integer(-1)); m.removeFirst ( ); m.remove(new Integer(-1));

*. Conditional universal prop: lastIndexOf(addFirst(S, m0_1).state, m0_2).retval == (lastIndexOf(S, m0_2).retval + 1) [where (m0_1==m0_2)]

Satisfying count: 120 (special test) LinkedList m = new LinkedList( );

m.addFirst(new Integer(-1)); m.lastIndexOf(new Integer(-1));

*. Common prop: removeLast(addFirst(S, m0_1).state).state

== addFirst(removeLast(S).state, m0_1).state Satisfying count: 117 (common test) LinkedList m = new LinkedList( );

m.add(0, new Integer(-1)); m.addFirst(new Integer(0)); m.removeLast ( );Violating count: 3 (special test) LinkedList m = new LinkedList( );

m.addFirst(new Integer(0)); m.removeLast ( );

http://www.cs.washington.edu/homes/taoxie/sabicu/