Moles: Tool-Assisted Environment Isolation with Closures

  • Jonathan de Halleux
  • Nikolai Tillmann
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6141)

Abstract

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.

Keywords

Unit Test Symbolic Execution Visual Studio Instance Method Automate Test Generation 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Elbaum, S., Chin, H.N., Dwyer, M.B., Dokulil, J.: Carving differential unit test cases from system test cases. In: Proceedings of the 14th ACM SIGSOFT international symposium on Foundations of software engineering, pp. 253–264. ACM, New York (2006)CrossRefGoogle Scholar
  2. 2.
    Feathers, M.: Working Effectively with Legacy Code. Prentice Hall PTR, Englewood Cliffs (September 2004)Google Scholar
  3. 3.
    Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading (1999)Google Scholar
  4. 4.
    Godefroid, P., Klarlund, N., Sen, K.: DART: directed automated random testing. SIGPLAN Notices 40(6), 213–223 (2005)CrossRefGoogle Scholar
  5. 5.
    Guttag, J.V., Horning, J.J.: The algebraic specification of abstract data types. Acta Informatica 10, 27–52 (1978)MATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Hunt, G., Brubacher, D.: Detours: binary interception of win32 functions. In: WINSYM’99: Proceedings of the 3rd conference on USENIX Windows NT Symposium, Berkeley, CA, USA, pp. 14. USENIX Association (1999)Google Scholar
  7. 7.
    JMockit developers. The JMockit testing toolkit (January 2010), http://jmockit.googlecode.com/svn/trunk/www/about.html
  8. 8.
    Joshi, S., Orso, A.: SCARPE: A technique and tool for selective record and replay of program executions. In: Proceedings of the 23rd IEEE International Conference on Software Maintenance (ICSM 2007), Paris, France (October 2007)Google Scholar
  9. 9.
    Micallef, J.: Encapsulation, reusability and extensibility in object-oriented programming languages. Journal of Object-Oriented Programming, 12–36 (April/May 1988)Google Scholar
  10. 10.
    Microsoft. Windows sharepoint services 3.0. (January 2010),http://technet.microsoft.com/en-us/windowsserver/sharepoint/default.aspx
  11. 11.
    Musuvathi, M., Qadeer, S., Ball, T., Basler, G., Nainar, P.A., Neamtiu, I.: Finding and reproducing heisenbugs in concurrent programs. In: OSDI, pp. 267–280 (2008)Google Scholar
  12. 12.
    Orso, A., Joshi, S., Burger, M., Zeller, A.: Isolating relevant Component Interactions with JINSI. In: Proceedings of the Fourth International ICSE Workshop on Dynamic Analysis (WODA 2006), Shanghai, China, May 2006, pp. 3–9 (2006)Google Scholar
  13. 13.
    Pasternak, B., Tyszberowicz, S., Yehudai, A.: GenUTest: a unit test and mock aspect generation tool. Int. J. Softw. Tools Technol. Transf. 11(4), 273–290 (2009)CrossRefGoogle Scholar
  14. 14.
    Pex development team. Pex (2008), http://research.microsoft.com/Pex
  15. 15.
    Pex development team. Unit testing SharePoint Foundation with Microsoft Pex and Moles (April 2010), http://research.microsoft.com/pex/pexsharepoint.pdf
  16. 16.
    Rho, T., Kniesel, G.: Uniform genericity for aspect languages. Technical report, Needs, Options and Challenges, Special issue of L’Objet. Hermes Science Publishing (2004)Google Scholar
  17. 17.
    Saff, D., Artzi, S., Perkins, J.H., Ernst, M.D.: Automatic test factoring for Java. In: ASE ’05: Proceedings of the 20th IEEE/ACM International Conference on Automated Software Engineering, pp. 114–123. ACM Press, New York (2005)CrossRefGoogle Scholar
  18. 18.
    Tillmann, N., de Halleux, J.: Pex - white box test generation for .NET. In: Beckert, B., Hähnle, R. (eds.) TAP 2008. LNCS, vol. 4966, pp. 134–153. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  19. 19.
    Tillmann, N., Schulte, W.: Parameterized unit tests. In: Proceedings of the 10th European Software Engineering Conference held jointly with 13th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 253–262. ACM, New York (2005)Google Scholar
  20. 20.
  21. 21.
    Xu, G., Rountev, A., Tang, Y., Qin, F.: Efficient checkpointing of java software using context-sensitive capture and replay. In: ESEC-FSE ’07: Proceedings of the the 6th joint meeting of the European software engineering conference and the ACM SIGSOFT symposium on the foundations of software engineering, pp. 85–94. ACM, New York (2007)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Jonathan de Halleux
    • 1
  • Nikolai Tillmann
    • 1
  1. 1.Microsoft ResearchRedmondUSA

Personalised recommendations