Combined Static and Dynamic Automated Test Generation
Sai Zhang University of Washington
Joint work with: David Saff, Yingyi Bu, Michael D. Ernst
1
Combined Static and Dynamic Automated Test Generation Sai Zhang - - PowerPoint PPT Presentation
Combined Static and Dynamic Automated Test Generation Sai Zhang University of Washington Joint work with: David Saff, Yingyi Bu, Michael D. Ernst 1 Unit Testing for Object-oriented Programs Unit test = sequence of method calls + testing oracle
1
2
public void testConnection() { Driver driver = new Driver(); Connection connection = driver.connect("jdbc:tinysql"); Statement s = connection.createStmt(); s.execute("create table test (name char(25))"); .... s.close(); connection.close(); }
Constraint 1: Method-call orders Constraint 2: Argument values
3
Capture method-call order and argument constraints
Expand the (incomplete) dynamic model
Fuzz along a specific legal path
4
5
(Optional)
Dynamic Model Method Dependence Testing Oracles
6
7
8
Driver d = new Driver();
9
Driver class
Connection con = driver.connect(“jdbc:dbname”);
10
Driver.connect(“jdbc:dbname”) Connection class
Driver class
Connection con = driver.connect(“jdbc:dbname”); con.close();
11
close()
Driver.connect(“jdbc:dbname”) Connection class
Driver class
Statement stmt1 = new Statement(con); stmt1.executeQuery(“select * from table_name”); stmt1.close();
Driver class
close()
Driver.connect(“jdbc:dbname”)
Statement stmt1
close()
executeQuery(“select * ..”); <init>(Connection) Connection class
12
Statement stmt2 = new Statement(con); stmt2.executeUpdate(“drop table table_name”); stmt2.close();
Driver class
close()
executeQuery(“select * ..”); <init>(Connection)
close()
executeUpdate(“drop * ..”); <init>(Connection)
close()
Driver.connect(“jdbc:dbname”)
13
Connection class Statement stmt1 Statement stmt2
Merge
Driver class Connection class
close()
executeUpdate(“drop * ..”); <init>(Connection) Statement stmt2
close()
Driver.connect(“jdbc:dbname”)
14
Statement stmt1
close()
executeQuery(“select * ..”); <init>(Connection)
15
Driver class
close()
Driver.connect(“jdbc:dbname”) Connection class
Statement class
close()
executeQuery(“select * ..”); <init>(Connection) executeUpdate(“drop * ..”);
close()
executeQuery(“select * ..”); <init>(Connection) executeUpdate (“drop * ..”);
16
Statement class
17
Driver class
close()
executeQuery(“select * ..”); <init>(Connection)
close() Driver.connect(“jdbc:dbname”) executeUpdate(“drop * ..”);
18
Connection class Statement class
19
Driver driver; String url; String usr;
{driver != null, url != null, usr != null}
{driver != null, url != null, usr !=null}
20
21
Write-read: method A reads a field that method B writes Read-read: methods A and B reference the same field
22
Statement.close();
Statement.executeQuery(“…”)
23
24
25
public void checkIterNoException(Iterator it) { assumeNotNull(it); try { it.hasNext(); } catch (Exception e) { fail(“hasNext() should never throw exception!”); } }
26
27
28
29
30
Palus increases test coverage
Palus falls back to pure random approach for programs
31
32
FilterListIterator.hasNext() throws exception
33
34
35
36
37
38
39
40