Automated Test Generation

17
Automated Test Generation 19 Recent advanced technique: Dynamic Symbolic Execution/Concolic Testing Instrument code to explore feasible paths Example tool: Pex from Microsoft Research (for .NET programs) P. Godefroid, N. Klarlund, and K. Sen. DART: directed automated random testing. In Proc. PLDI 2005 K. Sen, D. Marinov, and G. Agha. CUTE: a concolic unit testing engine for C. In Proc. ESEC/FSE 2005 N. Tillmann and J. de Halleux. Pex - White Box Test Generation for .NET. In Proc. TAP 2008

description

Automated Test Generation. Recent advanced technique: Dynamic Symbolic Execution/ Concolic Testing Instrument code to explore feasible paths Example tool: Pex from Microsoft Research (for .NET programs). - PowerPoint PPT Presentation

Transcript of Automated Test Generation

Page 1: Automated Test Generation

Automated Test Generation

19

Recent advanced technique: Dynamic Symbolic Execution/Concolic Testing Instrument code to explore feasible paths

Example tool: Pex from Microsoft Research (for .NET programs)

P. Godefroid, N. Klarlund, and K. Sen. DART: directed automated random testing. In Proc. PLDI 2005K. Sen, D. Marinov, and G. Agha. CUTE: a concolic unit testing engine for C. In Proc. ESEC/FSE 2005N. Tillmann and J. de Halleux. Pex - White Box Test Generation for .NET. In Proc. TAP 2008

Page 2: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

 

         

   

 

 

 

 

 

 

 

                 

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 3: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

 

         

   

 

Input

null 

 

 

 

                 

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 4: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

Ta==null

 

         

   

 

Input

null 

 

 

Execute&Monitor

Observed constraints

a==null               

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 5: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

Ta==null

Constraints to solve

a!=null    

   

 

Input

null 

 

 

Execute&Monitor

Choose next path

Observed constraints

a==null               

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 6: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

Ta==null

Constraints to solve

a!=null    

   

 

Input

null{}

 

 

Execute&MonitorSolve

Choose next path

Observed constraints

a==null               

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 7: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0F

TFa==null

Constraints to solve

a!=null    

   

 

Input

null{}

 

 

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)           

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 8: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0F

TFa==null

Constraints to solve

a!=null a!=null &&a.Length>0 

   

 

Input

null{}

 

 

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)           

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 9: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0

a[0]==123…

TF

T

F

Fa==null

Constraints to solve

a!=null a!=null &&a.Length>0 

   

 

Input

null{}

{0}

 

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)           

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 10: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0

a[0]==123…

TF

T

F

Fa==null

Constraints to solve

a!=null a!=null &&a.Length>0 

   

 

Input

null{}

{0}

 

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)a==null &&a.Length>0 &&a[0]!=1234567890     

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 11: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0

a[0]==123…

TF

T

F

Fa==null

Constraints to solve

a!=null a!=null &&a.Length>0 a!=null &&a.Length>0 &&a[0]==123456890

Input

null{}

{0}

 

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)a==null &&a.Length>0 &&a[0]!=1234567890     

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 12: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0

a[0]==123…

TF

T

F

Fa==null

Constraints to solve

a!=null a!=null &&a.Length>0 a!=null &&a.Length>0 &&a[0]==123456890

Input

null{}

{0}

{123…}

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)a==null &&a.Length>0 &&a[0]!=1234567890     

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 13: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0

a[0]==123…

TF

T

F

Fa==null

T

Constraints to solve

a!=null a!=null &&a.Length>0 a!=null &&a.Length>0 &&a[0]==123456890

Input

null{}

{0}

{123…}

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)a==null &&a.Length>0 &&a[0]!=1234567890a==null &&a.Length>0 &&a[0]==1234567890

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 14: Automated Test Generation

void CoverMe(int[] a){ if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug");}

a.Length>0

a[0]==123…

TF

T

F

Fa==null

T

Constraints to solve

a!=null a!=null &&a.Length>0 a!=null &&a.Length>0 &&a[0]==123456890

Input

null{}

{0}

{123…}

Execute&MonitorSolve

Choose next path

Observed constraints

a==nulla!=null &&!(a.Length>0)a==null &&a.Length>0 &&a[0]!=1234567890a==null &&a.Length>0 &&a[0]==1234567890

Done: There is no path left.

Dynamic Symbolic Execution in Pex

http://pex4fun.com/HowDoesPexWork

Page 15: Automated Test Generation

Automating Test Generation

• Method sequences – MSeqGen/Seeker [Thummalapenta et al. OOSPLA 11, ESEC/FSE 09],

Covana [Xiao et al. ICSE 2011], OCAT [Jaygarl et al. ISSTA 10], Evacon [Inkumsah et al. ASE 08], Symclat [d'Amorim et al. ASE 06]

• Environments e.g., db, file systems, network, …– DBApp Testing [Taneja et al. ESEC/FSE 11], [Pan et al. ASE 11]

– CloudApp Testing [Zhang et al. IEEE Soft 12]

• Loops – Fitnex [Xie et al. DSN 09]

@NCSU ASE

http://people.engr.ncsu.edu/txie/publications.htm

Page 16: Automated Test Generation

Pex on MSDN DevLabsIncubation Project for Visual Studio

Download counts (20 months)(Feb. 2008 - Oct. 2009 )

Academic: 17,366 Devlabs: 13,022 Total: 30,388

http://research.microsoft.com/projects/pex/

Page 17: Automated Test Generation

Testing Tool Educational Gaming

DSE/Pex

secret

Pex for Fun:

Interactive Gaming for

Teaching and Learning

Support

http://research.microsoft.com/pex/ http://pex4fun.com