Skip to main content

Reusing and Composing Tests with Traits

  • Conference paper
Objects, Components, Models and Patterns (TOOLS EUROPE 2009)

Part of the book series: Lecture Notes in Business Information Processing ((LNBIP,volume 33))

Included in the following conference series:

Abstract

Single inheritance often forces developers to duplicate code and logic. This widely recognized situation affects both business code and tests. In a large and complex application whose classes implement many groups of methods (protocols), duplication may also follow the application’s idiosyncrasies, making it difficult to specify, maintain, and reuse tests. The research questions we faced are (i) how can we reuse test specifications across and within complex inheritance hierarchies, especially in presence of orthogonal protocols; (ii) how can we test interface behavior in a modular way; (iii) how far can we reuse and parametrize composable tests.

In this paper, we compose tests out of separately specified behavioral units of reuse —traits. We propose test traits, where: (i) specific test cases are composed from independent specifications; (ii) executable behavior specifications may be reused orthogonally to the class hierarchy under test; (iii) test fixtures are external to the test specifications, thus are easier to specialize. Traits have been successfully applied to test two large and critical class libraries in Pharo, a new Smalltalk dialect based on Squeak, but are applicable to other languages with traits.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. ANSI. American National Standard for Information Systems—Programming Languages—Smalltalk, ANSI/INCITS 319-1998 (1998)

    Google Scholar 

  2. Beck, K.: Simple Smalltalk testing: With patterns, http://www.xprogramming.com/testfram.htm

  3. Black, A.P., Schärli, N.: Traits: Tools and methodology. In: ICSE (2004)

    Google Scholar 

  4. Black, A.P., Schärli, N., Ducasse, S.: Applying traits to the Smalltalk collection hierarchy. In: OOPSLA, vol. 38, pp. 47–64 (2003)

    Google Scholar 

  5. Cassou, D., Ducasse, S., Wuyts, R.: Traits at work: the design of a new trait-based stream library. Journal of Computer Languages, Systems and Structures 35(1), 2–20 (2009)

    Article  Google Scholar 

  6. Cook, W.R.: Interfaces and specifications for the Smalltalk-80 collection classes. In: OOPSLA, vol. 27, pp. 1–15. ACM Press, New York (1992)

    Google Scholar 

  7. Dedecker, J., Van Cutsem, T., Mostinckx, S., D’Hondt, T., De Meuter, W.: Ambient-oriented programming in ambientTalk. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 230–254. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  8. Ducasse, S., Gîrba, T., Wuyts, R.: Object-oriented legacy system trace-based logic testing. In: European Conference on Software Maintenance and Reengineering (CSMR 2006), pp. 35–44. IEEE Computer Society Press, Los Alamitos (2006)

    Google Scholar 

  9. Flatt, M., Finder, R.B., Felleisen, M.: Scheme with classes, mixins and traits. In: AAPLAS (2006)

    Google Scholar 

  10. The Fortress language specification, http://research.sun.com/projects/plrg/fortress0866.pdf

  11. Godin, R., Mili, H., Mineau, G.W., Missaoui, R., Arfi, A., Chau, T.-T.: Design of class hierarchies based on concept (Galois) lattices. Theory and Application of Object Systems 4(2), 117–134 (1998)

    Google Scholar 

  12. Ingalls, D., Kaehler, T., Maloney, J., Wallace, S., Kay, A.: Back to the future: The story of Squeak, a practical Smalltalk written in itself. In: OOPSLA, pp. 318–326. ACM Press, New York (1997)

    Chapter  Google Scholar 

  13. LaLonde, W., Pugh, J.: Subclassing ≠ Subtyping ≠ Is-a. Journal of Object-Oriented Programming 3(5), 57–62 (1991)

    Google Scholar 

  14. Meszaros, G.: XUnit Test Patterns – Refactoring Test Code. Addison-Wesley, Reading (2007)

    Google Scholar 

  15. Renggli, L.: Magritte — Meta-described web application development. Master’s thesis, University of Bern (2006)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Ducasse, S., Pollet, D., Bergel, A., Cassou, D. (2009). Reusing and Composing Tests with Traits. In: Oriol, M., Meyer, B. (eds) Objects, Components, Models and Patterns. TOOLS EUROPE 2009. Lecture Notes in Business Information Processing, vol 33. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-02571-6_15

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-02571-6_15

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-02570-9

  • Online ISBN: 978-3-642-02571-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics