Moles: Tool-Assisted Environment Isolation with Closures

Isolating test cases from environment dependencies is often desirable, as it increases test reliability and reduces test execution time. However, code that calls non-virtual methods or consumes sealed classes is often impossible to test in isolation. Moles is a new lightweight framework which addresses this problem. For any .NET method, Moles allows test-code to provide alternative implementations, given as .NET delegates, for which C# provides very concise syntax while capturing local variables in a closure object. Using code instrumentation, the Moles framework will redirect calls to provided delegates instead of the original methods. The Moles framework is designed to work together with the dynamic symbolic execution tool Pex to enable automated test generation. In a case study, testing code programmed against the Microsoft SharePoint Foundation API, we achieved full code coverage while running tests in isolation without an actual SharePoint server. The Moles framework integrates with .NET and Visual Studio.

[1]  Isolating relevant component interactions with JINSI , 2006, WODA '06.

[2]  Josephine Micallef,et al.  Encapsulation, Reusability and Extensibility in Object-Oriented Programming Languages , 1987 .

[3]  James J. Horning,et al.  The algebraic specification of abstract data types , 1978, Acta Informatica.

[4]  Romain Robbes,et al.  Recovering inter-project dependencies in software ecosystems , 2010, ASE.

[5]  Thomas Ball,et al.  Finding and Reproducing Heisenbugs in Concurrent Programs , 2008, OSDI.

[6]  Michael D. Ernst,et al.  Automatic test factoring for java , 2005, ASE '05.

[7]  Nikolai Tillmann,et al.  Parameterized unit tests , 2005, ESEC/FSE-13.

[8]  Matthew B. Dwyer,et al.  Carving differential unit test cases from system test cases , 2006, SIGSOFT '06/FSE-14.

[9]  Amiram Yehudai,et al.  GenUTest: a unit test and mock aspect generation tool , 2007, International Journal on Software Tools for Technology Transfer.

[10]  Nikolai Tillmann,et al.  Pex-White Box Test Generation for .NET , 2008, TAP.

[11]  Günter Kniesel,et al.  Uniform Genericity for Aspect Languages , 2004 .

[12]  Alessandro Orso,et al.  SCARPE: A Technique and Tool for Selective Capture and Replay of Program Executions , 2007, 2007 IEEE International Conference on Software Maintenance.

[13]  Galen C. Hunt,et al.  Detours: binary interception of Win32 functions , 1999 .

[14]  Yan Tang,et al.  Efficient checkpointing of java software using context-sensitive capture and replay , 2007, ESEC-FSE '07.

[15]  Michael C. Feathers Working Effectively with Legacy Code , 2004, XP/Agile Universe.

[16]  Koushik Sen,et al.  DART: directed automated random testing , 2005, PLDI '05.