1
Tool-Assisted Unit Test Selection Based on Operational Violations
Tao Xie David Notkin
Department of Computer Science & Engineering University of Washington, Seattle, WA
- Oct. 8th, 2003
ASE 2003, Montreal, Canada
Tool-Assisted Unit Test Selection Based on Operational Violations - - PowerPoint PPT Presentation
Tool-Assisted Unit Test Selection Based on Operational Violations Tao Xie David Notkin Department of Computer Science & Engineering University of Washington, Seattle, WA Oct. 8th, 2003 ASE 2003, Montreal, Canada 1 Synopsis Context:
1
Department of Computer Science & Engineering University of Washington, Seattle, WA
ASE 2003, Montreal, Canada
2
3
4
5
Program
Automatically generated test inputs
White-box gen
Specs Oracles
Black-box gen
6
Jtest
Up to range(1…3) method calls in a test
7
8
Jtest
9
10
DbC comments Annotated program
Data trace
Violating tests Automatically generated test inputs Violated OA Selected tests
All OA OA: Operational Abstractions The existing test suite (manual tests) Program
11
@Pre @Post @Inv The existing test suite
Run
Data trace
Detect invariants Insert as
DbC comments program
Program Annotated @Pre
12
public class uniqueBoundedStack { private int[] elems; private int numberOfElements; private int max; public uniqueBoundedStack() { numberOfElements = 0; max = 2; elems = new int[max]; } public int getNumberOfElements() { return numberOfElements; } …… };
13
public int top(){ if (numberOfElements < 1) { System.out.println("Empty Stack"); return -1; } else { return elems[numberOfElements-1]; } }
@pre { for (int i = 0 ; i <= this.elems.length-1; i++) $assert ((this.elems[i] >= 0)); }
@post: [($result == -1) (this.numberOfElements == 0)]
uniqueBoundedStack THIS = new uniqueBoundedStack (); THIS.push (-1); int RETVAL = THIS.top ();
14
The existing test suite
Run
Data trace
Detect invariants Insert as DbC comments Run & Check
Violating tests Annotated program
Automatically generated test inputs
Violated OA
Select
OA Selected tests
Program
15
16
17
18
19
20
21
22
23
24
25
26
27
& Young 99][Rothermel et al. 01][Srivastava & Thiagarajan 02]
28
29
30
31
Program The existing test suite Operational abstractions
Automatically generated test inputs
Selected tests
32
Program The existing test suite Operational abstractions
Automatically generated test inputs
Selected tests
Add preconditions/defensive programming (illegal inputs)
Fix bugs (faults exposed by legal inputs) Add oracles/augment