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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
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)
Feathers, M.: Working Effectively with Legacy Code. Prentice Hall PTR, Englewood Cliffs (September 2004)
Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading (1999)
Godefroid, P., Klarlund, N., Sen, K.: DART: directed automated random testing. SIGPLAN Notices 40(6), 213–223 (2005)
Guttag, J.V., Horning, J.J.: The algebraic specification of abstract data types. Acta Informatica 10, 27–52 (1978)
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)
JMockit developers. The JMockit testing toolkit (January 2010), http://jmockit.googlecode.com/svn/trunk/www/about.html
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)
Micallef, J.: Encapsulation, reusability and extensibility in object-oriented programming languages. Journal of Object-Oriented Programming, 12–36 (April/May 1988)
Microsoft. Windows sharepoint services 3.0. (January 2010), http://technet.microsoft.com/en-us/windowsserver/sharepoint/default.aspx
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)
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)
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)
Pex development team. Pex (2008), http://research.microsoft.com/Pex
Pex development team. Unit testing SharePoint Foundation with Microsoft Pex and Moles (April 2010), http://research.microsoft.com/pex/pexsharepoint.pdf
Rho, T., Kniesel, G.: Uniform genericity for aspect languages. Technical report, Needs, Options and Challenges, Special issue of L’Objet. Hermes Science Publishing (2004)
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)
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)
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)
TypeMock Development Team. Isolator, http://www.typemock.com/learn_about_typemock_isolator.html
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
de Halleux, J., Tillmann, N. (2010). Moles: Tool-Assisted Environment Isolation with Closures. In: Vitek, J. (eds) Objects, Models, Components, Patterns. TOOLS 2010. Lecture Notes in Computer Science, vol 6141. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-13953-6_14
Download citation
DOI: https://doi.org/10.1007/978-3-642-13953-6_14
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-13952-9
Online ISBN: 978-3-642-13953-6
eBook Packages: Computer ScienceComputer Science (R0)