Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
Skip header Section
XUnit Test Patterns: Refactoring Test CodeMay 2006
Publisher:
  • Prentice Hall PTR
  • Upper Saddle River, NJ
  • United States
ISBN:978-0-13-149505-0
Published:01 May 2006
Skip Bibliometrics Section
Reflects downloads up to 21 Sep 2024Bibliometrics
Skip Abstract Section
Abstract

Automated testing is a cornerstone of agile development. An effective testing strategy will deliver new functionality more aggressively, accelerate user feedback, and improve quality. However, for many developers, creating effective automated tests is a unique and unfamiliar challenge.xUnit Test Patterns is the definitive guide to writing automated tests using xUnit, the most popular unit testing framework in use today. Agile coach and test automation expert Gerard Meszaros describes 68 proven patterns for making tests easier to write, understand, and maintain. He then shows you how to make them more robust and repeatable--and far more cost-effective.Loaded with information, this book feels like three books in one. The first part is a detailed tutorial on test automation that covers everything from test strategy to in-depth test coding. The second part, a catalog of 18 frequently encountered "test smells," provides trouble-shooting guidelines to help you determine the root cause of problems and the most applicable patterns. The third part contains detailed descriptions of each pattern, including refactoring instructions illustrated by extensive code samples in multiple programming languages.Topics covered include Writing better tests--and writing them faster The four phases of automated tests: fixture setup, exercising the system under test, result verification, and fixture teardown Improving test coverage by isolating software from its environment using Test Stubs and Mock Objects Designing software for greater testability Using test "smells" (including code smells, behavior smells, and project smells) to spot problems and know when and how to eliminate them Refactoring tests for greater simplicity, robustness, and execution speedThis book will benefit developers, managers, and testers working with any agile or conventional development process, whether doing test-driven development or writing the tests last. While the patterns and smells are especially applicable to all members of the xUnit family, they also apply to next-generation behavior-driven development frameworks such as RSpec and JBehave and to other kinds of test automation tools, including recorded test tools and data-driven test tools such as Fit and FitNesse.Visual Summary of the Pattern Languageï Foreword Preface Acknowledgments Introduction Refactoring a TestPART I: The Narratives Chapter 1 A Brief Tour Chapter 2 Test Smells Chapter 3 Goals of Test Automation Chapter 4 Philosophy of Test Automation Chapter 5 Principles of Test Automation Chapter 6 Test Automation Strategy Chapter 7 xUnit Basics Chapter 8 Transient Fixture Management Chapter 9 Persistent Fixture Management Chapter 10 Result Verification Chapter 11 Using Test Doubles Chapter 12 Organizing Our Tests Chapter 13 Testing with Databases Chapter 14 A Roadmap to Effective Test Automation PART II: The Test Smellsï Chapter 15 Code Smells Chapter 16 Behavior Smells Chapter 17 Project Smells PART III: The Patternsï Chapter 18 Test Strategy Patterns Chapter 19 xUnit Basics Patterns Chapter 20 Fixture Setup Patterns Chapter 21 Result Verification Patterns Chapter 22 Fixture Teardown Patterns Chapter 23 Test Double Patterns Chapter 24 Test Organization Patterns Chapter 25 Database Patterns Chapter 26 Design-for-Testability Patterns Chapter 27 Value Patterns PART IV: Appendixes Appendix A Test Refactorings ï Appendix B xUnit Terminologyï Appendix C xUnit Family Members Appendix D Tools Appendix E Goals and Principles Appendix F Smells, Aliases, and Causes Appendix G Patterns, Aliases, and Variations Glossary Referencesï Indexï

Cited By

  1. ACM
    Aranda M, Oliveira N, Soares E, Ribeiro M, Romão D, Patriota U, Gheyi R, Souza E and Machado I A Catalog of Transformations to Remove Smells From Natural Language Tests Proceedings of the 28th International Conference on Evaluation and Assessment in Software Engineering, (7-16)
  2. Martins L, Ghaleb T, Costa H and Machado I (2024). A comprehensive catalog of refactoring strategies to handle test smells in Java-based systems, Software Quality Journal, 32:2, (641-679), Online publication date: 1-Jun-2024.
  3. ACM
    Yang Y, Hu X, Xia X and Yang X (2024). The Lost World: Characterizing and Detecting Undiscovered Test Smells, ACM Transactions on Software Engineering and Methodology, 33:3, (1-32), Online publication date: 31-Mar-2024.
  4. Morales I, Martínez-Hornak L, Solari A and Oreggioni J (2024). Respiratory Rate Estimation on Embedded System, IEEE Embedded Systems Letters, 16:1, (65-68), Online publication date: 1-Mar-2024.
  5. ACM
    Pizzini A, Reinehr S and Malucelli A Sentinel: A process for automatic removing of Test Smells Proceedings of the XXII Brazilian Symposium on Software Quality, (80-89)
  6. ACM
    De Almeida R, Da Silva R, Serrano L, De Souza Campos Junior H and De Oliveira Neves V Mock Objects in Software Testing: An Analysis of Usage in Open-Source Projects Proceedings of the XXII Brazilian Symposium on Software Quality, (72-79)
  7. ACM
    Rzig D, Iqbal N, Attisano I, Qin X and Hassan F Virtual Reality (VR) Automated Testing in the Wild: A Case Study on Unity-Based VR Applications Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis, (1269-1281)
  8. ACM
    Zarras A Two Patterns, a study and a message for the validation of our patterns Proceedings of the 28th European Conference on Pattern Languages of Programs, (1-6)
  9. ACM
    Christensen H Teaching Distributed Programming – Revisiting the Broker Pattern Proceedings of the 5th European Conference on Software Engineering Education, (162-168)
  10. ACM
    Ibarra C, De Faria D, Endo A, Beder D and Vincenzi A Mock objects: a case study in industry✱ Proceedings of the XIX Brazilian Symposium on Information Systems, (396-403)
  11. Aljedaani W, Mkaouer M, Peruma A and Ludi S Do the Test Smells Assertion Roulette and Eager Test Impact Students' Troubleshooting and Debugging Capabilities? Proceedings of the 45th International Conference on Software Engineering: Software Engineering Education and Training, (29-39)
  12. Wei C, Xiao L, Yu T, Chen X, Wang X, Wong S and Clune A (2023). Automatically Tagging the “AAA” Pattern in Unit Test Cases Using Machine Learning Models, IEEE Transactions on Software Engineering, 49:5, (3305-3324), Online publication date: 1-May-2023.
  13. Wang X, Xiao L, Yu T, Woepse A and Wong S (2023). From Inheritance to Mockito: An Automatic Refactoring Approach, IEEE Transactions on Software Engineering, 49:4, (2791-2814), Online publication date: 1-Apr-2023.
  14. Ding Y, Zhang Y, Yuan G, Jiang S and Dai W (2023). Progress on class integration test order generation approaches, Information and Software Technology, 156:C, Online publication date: 1-Apr-2023.
  15. Soares E, Ribeiro M, Gheyi R, Amaral G and Santos A (2023). Refactoring Test Smells With JUnit 5: Why Should Developers Keep Up-to-Date?, IEEE Transactions on Software Engineering, 49:3, (1152-1170), Online publication date: 1-Mar-2023.
  16. Kudo T, Bulcão-Neto R, Neto V and Vincenzi A (2023). Aligning requirements and testing through metamodeling and patterns: design and evaluation, Requirements Engineering, 28:1, (97-115), Online publication date: 1-Mar-2023.
  17. ACM
    Pizzini A, Reinehr S and Malucelli A Automatic Refactoring Method to Remove Eager Test Smell Proceedings of the XXI Brazilian Symposium on Software Quality, (1-10)
  18. ACM
    Mejstrik T and Hollomey C Injection testing backed refactoring Proceedings of the 27th European Conference on Pattern Languages of Programs, (1-7)
  19. García B, Delgado Kloos C, Alario-Hoyos C and Munoz-Organero M (2022). Selenium-Jupiter, Journal of Systems and Software, 189:C, Online publication date: 1-Jul-2022.
  20. Peng Z, Chen T and Yang J (2022). Revisiting Test Impact Analysis in Continuous Testing From the Perspective of Code Dependencies, IEEE Transactions on Software Engineering, 48:6, (1979-1993), Online publication date: 1-Jun-2022.
  21. ACM
    Fazzini M, Choi C, Copia J, Lee G, Kakehi Y, Gorla A and Orso A Use of test doubles in Android testing Proceedings of the 44th International Conference on Software Engineering, (2266-2278)
  22. Wang T, Golubev Y, Smirnov O, Li J, Bryksin T and Ahmed I PyNose Proceedings of the 36th IEEE/ACM International Conference on Automated Software Engineering, (593-605)
  23. Taniguchi M, Matsumoto S and Kusumoto S JTDog Proceedings of the 36th IEEE/ACM International Conference on Automated Software Engineering, (1271-1275)
  24. Aranega V, Delplanque J, Martinez M, Black A, Ducasse S, Etien A, Fuhrman C and Polito G (2021). Rotten green tests in Java, Pharo and Python, Empirical Software Engineering, 26:6, Online publication date: 1-Nov-2021.
  25. ACM
    Gonzalez D, Perez P and Mirakhorli M Barriers to Shift-Left Security Proceedings of the 15th ACM / IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM), (1-12)
  26. Kim D, Chen T and Yang J (2021). The secret life of test smells - an empirical study on test smell evolution and maintenance, Empirical Software Engineering, 26:5, Online publication date: 1-Sep-2021.
  27. ACM
    Buffardi K and Aguirre-Ayala J Unit Test Smells and Accuracy of Software Engineering Student Test Suites Proceedings of the 26th ACM Conference on Innovation and Technology in Computer Science Education V. 1, (234-240)
  28. Alshammari A, Morris C, Hilton M and Bell J FlakeFlagger Proceedings of the 43rd International Conference on Software Engineering, (1572-1584)
  29. Vidoni M Evaluating Unit Testing Practices in R Packages Proceedings of the 43rd International Conference on Software Engineering, (1523-1534)
  30. ACM
    Fazzini M, Gorla A and Orso A A framework for automated test mocking of mobile apps Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering, (1204-1208)
  31. ACM
    Peruma A, Almalki K, Newman C, Mkaouer M, Ouni A and Palomba F tsDetect: an open source test smells detection tool Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, (1650-1654)
  32. ACM
    Silva L and Vilain P LCCSS Proceedings of the 14th Brazilian Symposium on Software Components, Architectures, and Reuse, (91-100)
  33. ACM
    Pereira G, Nunes I and Pimenta M Test-case-based Code Navigation in Dynamically Typed Programming Languages Proceedings of the 14th Brazilian Symposium on Software Components, Architectures, and Reuse, (81-90)
  34. Peruma A, Almalki K, Newman C, Mkaouer M, Ouni A and Palomba F On the distribution of test smells in open source Android applications Proceedings of the 29th Annual International Conference on Computer Science and Software Engineering, (193-202)
  35. Grano G, Palomba F, Di Nucci D, De Lucia A and Gall H (2019). Scented since the beginning, Journal of Systems and Software, 156:C, (312-327), Online publication date: 1-Oct-2019.
  36. Palomba F and Zaidman A (2019). The smell of fear: on the relation between test smells and flaky tests, Empirical Software Engineering, 24:5, (2907-2946), Online publication date: 1-Oct-2019.
  37. ACM
    Kudo T, Bulcão-Neto R and Vincenzi A A Conceptual Metamodel to Bridging Requirement Patterns to Test Patterns Proceedings of the XXXIII Brazilian Symposium on Software Engineering, (155-160)
  38. Ghaleb T, Da Costa D and Zou Y (2019). An empirical study of the long duration of continuous integration builds, Empirical Software Engineering, 24:4, (2102-2139), Online publication date: 1-Aug-2019.
  39. ACM
    Laufer K, O'Sullivan J and Thiruvathukal G Tests as maintainable assets via auto-generated spies Proceedings of the Tenth ACM SIGPLAN Symposium on Scala, (17-21)
  40. ACM
    Rein P, Lincke J, Ramson S, Mattis T, Niephaus F and Hirschfeld R Implementing Babylonian/S by Putting Examples Into Contexts Proceedings of the 11th ACM International Workshop on Context-Oriented Programming, (17-23)
  41. ACM
    Grano G A new dimension of test quality: assessing and generating higher quality unit test cases Proceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis, (419-423)
  42. Gergely T, Balogh G, Horváth F, Vancsics B, Beszédes Á and Gyimóthy T (2019). Differences between a static and a dynamic test-to-code traceability recovery method, Software Quality Journal, 27:2, (797-822), Online publication date: 1-Jun-2019.
  43. Spadini D, Aniche M, Bruntink M and Bacchelli A (2019). Mock objects for testing java systems, Empirical Software Engineering, 24:3, (1461-1498), Online publication date: 1-Jun-2019.
  44. Kochhar P, Xia X and Lo D Practitioners' views on good software testing practices Proceedings of the 41st International Conference on Software Engineering: Software Engineering in Practice, (61-70)
  45. De Bleser J, Di Nucci D and De Roover C Assessing diffusion and perception of test smells in scala projects Proceedings of the 16th International Conference on Mining Software Repositories, (457-467)
  46. Delplanque J, Ducasse S, Polito G, Black A and Etien A Rotten green tests Proceedings of the 41st International Conference on Software Engineering, (500-511)
  47. ACM
    Medeiros H, Vilain P and Pereira V Reducing the execution time of unit tests of smart contracts in blockchain platforms Proceedings of the XV Brazilian Symposium on Information Systems, (1-8)
  48. ACM
    Fraser G, Gambi A, Kreis M and Rojas J Gamifying a Software Testing Course with Code Defenders Proceedings of the 50th ACM Technical Symposium on Computer Science Education, (571-577)
  49. ACM
    Aniche M, Hermans F and van Deursen A Pragmatic Software Testing Education Proceedings of the 50th ACM Technical Symposium on Computer Science Education, (414-420)
  50. Rodrigues M, Guimarães B and Pereira F Generation of in-bounds inputs for arrays in memory-unsafe languages Proceedings of the 2019 IEEE/ACM International Symposium on Code Generation and Optimization, (136-148)
  51. ACM
    Spadini D Practices and tools for better software testing Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, (928-931)
  52. ACM
    Li F, Fröhlich J, Schall D, Lachenmayr M, Stückjürgen C, Meixner S and Buschmann F Microservice Patterns for the Life Cycle of Industrial Edge Software Proceedings of the 23rd European Conference on Pattern Languages of Programs, (1-11)
  53. ACM
    Li B, Vendome C, Linares-Vásquez M and Poshyvanyk D Aiding comprehension of unit test cases and test suites with stereotype-based tagging Proceedings of the 26th Conference on Program Comprehension, (52-63)
  54. ACM
    Ma'ayan D The quality of junit tests Proceedings of the 1st International Workshop on Software Qualities and Their Dependencies, (33-36)
  55. ACM
    Schwichtenberg S, Jovanovikj I, Gerth C and Engels G CrossEcore Proceedings of the 40th International Conference on Software Engineering: Companion Proceeedings, (292-293)
  56. ACM
    Guarnieri M, Tsankov P, Buchs T, Torabi Dashti M and Basin D Test execution checkpointing for web applications Proceedings of the 26th ACM SIGSOFT International Symposium on Software Testing and Analysis, (203-214)
  57. Bowes D, Hall T, Petrić J, Shippey T and Turhan B How good are my tests? Proceedings of the 8th Workshop on Emerging Trends in Software Metrics, (9-14)
  58. Gonzalez D, Santos J, Popovich A, Mirakhorli M and Nagappan M A large-scale study on the usage of testing patterns that address maintainability attributes Proceedings of the 14th International Conference on Mining Software Repositories, (391-401)
  59. Beller M, Gousios G and Zaidman A Oops, my tests broke the build Proceedings of the 14th International Conference on Mining Software Repositories, (356-367)
  60. Spadini D, Aniche M, Bruntink M and Bacchelli A To mock or not to mock? Proceedings of the 14th International Conference on Mining Software Repositories, (402-412)
  61. Terceiro A Patterns for writing as-installed tests for Debian packages Proceedings of the 11th Latin-American Conference on Pattern Languages of Programming, (1-15)
  62. Ročkai P, Barnat J and Brim L (2016). Model checking C++ programs with exceptions, Science of Computer Programming, 128:C, (68-85), Online publication date: 15-Oct-2016.
  63. ACM
    Tufano M, Palomba F, Bavota G, Di Penta M, Oliveto R, De Lucia A and Poshyvanyk D An empirical investigation into the nature of test smells Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, (4-15)
  64. ACM
    Palomba F, Panichella A, Zaidman A, Oliveto R and De Lucia A Automatic test case generation: what if test code quality matters? Proceedings of the 25th International Symposium on Software Testing and Analysis, (130-141)
  65. ACM
    Christensen H Teaching DevOps and Cloud Computing using a Cognitive Apprenticeship and Story-Telling Approach Proceedings of the 2016 ACM Conference on Innovation and Technology in Computer Science Education, (174-179)
  66. ACM
    Palomba F, Di Nucci D, Panichella A, Oliveto R and De Lucia A On the diffusion of test smells in automatically generated test code Proceedings of the 9th International Workshop on Search-Based Software Testing, (5-14)
  67. Waterloo M, Person S and Elbaum S Test analysis Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering, (149-154)
  68. Fard A, Mesbah A and Wohlstadter E Generating fixtures for JavaScript unit testing Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering, (190-200)
  69. ACM
    Fang Z and Lam P Identifying Test Refactoring Candidates with Assertion Fingerprints Proceedings of the Principles and Practices of Programming on The Java Platform, (125-137)
  70. Klikovits S, Lawrence D, Gonzalez-Berges M and Buchs D Considering Execution Environment Resilience Proceedings of the 7th International Workshop on Software Engineering for Resilient Systems - Volume 9274, (46-61)
  71. ACM
    Bajada L, Micallef M and Colombo C Using control flow analysis to improve the effectiveness of incremental mutation testing Proceedings of the 14th International Workshop on Principles of Software Evolution, (73-78)
  72. ACM
    Beller M, Gousios G, Panichella A and Zaidman A When, how, and why developers (do not) test in their IDEs Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering, (179-190)
  73. ACM
    Daka E, Campos J, Fraser G, Dorn J and Weimer W Modeling readability to improve unit tests Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering, (107-118)
  74. ACM
    Parsai A, Murgia A, Soetens Q and Demeyer S Mutation testing as a safety net for test code refactoring Scientific Workshop Proceedings of the XP2015, (1-7)
  75. Hauptmann B, Juergens E and Woinke V Generating refactoring proposals to remove clones from automated system tests Proceedings of the 2015 IEEE 23rd International Conference on Program Comprehension, (115-124)
  76. Beller M, Gousios G and Zaidman A How (much) do developers test? Proceedings of the 37th International Conference on Software Engineering - Volume 2, (559-562)
  77. ACM
    Anslow C and Maurer F An Experience Report at Teaching a Group Based Agile Software Development Project Course Proceedings of the 46th ACM Technical Symposium on Computer Science Education, (500-505)
  78. ACM
    Xuan J and Monperrus M Test case purification for improving fault localization Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, (52-63)
  79. Guerra E, Moura P, Besson F, Rebouças A and Kon F Patterns for testing distributed systems interaction Proceedings of the 21st Conference on Pattern Languages of Programs, (1-8)
  80. ACM
    Ghafari M, Ghezzi C, Mocci A and Tamburrelli G Mining unit tests for code recommendation Proceedings of the 22nd International Conference on Program Comprehension, (142-145)
  81. ACM
    Islam M and Csallner C (2014). Generating Test Cases for Programs that Are Coded against Interfaces and Annotations, ACM Transactions on Software Engineering and Methodology, 23:3, (1-38), Online publication date: 1-May-2014.
  82. Qusef A, Bavota G, Oliveto R, De Lucia A and Binkley D (2014). Recovering test-to-code traceability using slicing and textual analysis, Journal of Systems and Software, 88:C, (147-168), Online publication date: 1-Feb-2014.
  83. Guerra E, Yoder J, Aniche M and Gerosa M Test-driven development step patterns for designing objects dependencies Proceedings of the 20th Conference on Pattern Languages of Programs, (1-15)
  84. Greiler M, Zaidman A, Deursen A and Storey M Strategies for avoiding text fixture smells during software evolution Proceedings of the 10th Working Conference on Mining Software Repositories, (387-396)
  85. Hauptmann B, Junker M, Eder S, Heinemann L, Vaas R and Braun P Hunting for smells in natural language tests Proceedings of the 2013 International Conference on Software Engineering, (1217-1220)
  86. Guerra E Fundamental test driven development step patterns Proceedings of the 19th Conference on Pattern Languages of Programs, (1-15)
  87. ACM
    Farias G, Dantas A, Lopes R and Guerrero D Distributed test agents Proceedings of the 9th Latin-American Conference on Pattern Languages of Programming, (1-11)
  88. ACM
    Guerra E and Kinoshita B Patterns for introducing a superclass for test classes Proceedings of the 9th Latin-American Conference on Pattern Languages of Programming, (1-12)
  89. Rüegg M and Sommerlad P Refactoring towards seams in C++ Proceedings of the 7th International Workshop on Automation of Software Test, (117-123)
  90. Greiler M, van Deursen A and Zaidman A Measuring test case similarity to support test suite understanding Proceedings of the 50th international conference on Objects, Models, Components, Patterns, (91-107)
  91. ACM
    Majchrzak T and Simon A Using spring Roo for the test-driven development of Web applications Proceedings of the 27th Annual ACM Symposium on Applied Computing, (664-671)
  92. King T, Ganti A and Froslie D Enabling automated integration testing of cloud application services in virtualized environments Proceedings of the 2011 Conference of the Center for Advanced Studies on Collaborative Research, (120-132)
  93. ACM
    Floriano M, Chama D, Guerra E and Silveira F The annotated test step pattern Proceedings of the 18th Conference on Pattern Languages of Programs, (1-10)
  94. van Welbergen H, Xu Y, Thiebaux M, Feng W, Fu J, Reidsma D and Shapiro A Demonstrating and testing the BML compliance of BML realizers Proceedings of the 10th international conference on Intelligent virtual agents, (269-281)
  95. ACM
    Araya V Test blueprint Proceedings of the 33rd International Conference on Software Engineering, (1140-1142)
  96. Hatebur D and Heisel M Making pattern- and model-based software development more rigorous Proceedings of the 12th international conference on Formal engineering methods and software engineering, (253-269)
  97. ACM
    Meszaros G XUnit test patterns and smells Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion, (299-300)
  98. Nandigam J, Tao Y, Gudivada V and Hamou-Lhadj A (2010). Using mock object frameworks to teach object-oriented design principles, Journal of Computing Sciences in Colleges, 26:1, (40-48), Online publication date: 1-Oct-2010.
  99. ACM
    Wolfmaier K, Ramler R and Dobler H Issues in testing collection class libraries Proceedings of the 1st Workshop on Testing Object-Oriented Systems, (1-8)
  100. ACM
    Rivas S, Francisco M and Gulías V Property driven development in Erlang, by example Proceedings of the 5th Workshop on Automation of Software Test, (75-78)
  101. Koochakzadeh N and Garousi V (2010). A tester-assisted methodology for test redundancy detection, Advances in Software Engineering, 2010, (1-13), Online publication date: 1-Jan-2010.
  102. ACM
    Rayside D, Milicevic A, Yessenov K, Dennis G and Jackson D Agile specifications Proceedings of the 24th ACM SIGPLAN conference companion on Object oriented programming systems languages and applications, (999-1006)
  103. Coyne M, Graham S, Hopkinson K and Kurkowski S A methodology for unit testing actors in proprietary discrete event based simulations Proceedings of the 40th Conference on Winter Simulation, (1012-1019)
  104. ACM
    Dantas A Improving developers' confidence in test results of multi-threaded systems Companion to the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications, (899-900)
  105. Van Rompaey B, Du Bois B, Demeyer S and Rieger M (2007). On The Detection of Test Smells, IEEE Transactions on Software Engineering, 33:12, (800-817), Online publication date: 1-Dec-2007.
  106. Lanubile F and Mallardo T Inspecting automated test code Proceedings of the 8th international conference on Agile processes in software engineering and extreme programming, (115-122)
Contributors
  • Nortel Networks

Reviews

Fernando Berzal

Originally developed by Kent Beck and Eric Gamma for its use in extreme programming [1], JUnit is an automated unit-testing framework for the Java programming language. In fact, it is just an instance of the xUnit testing framework family. Albeit typically associated with test-driven development [2], xUnit can be extremely helpful whether you write code test first or not, since automated unit tests provide an invaluable safety net for relentless refactoring, apart from their use as code documentation or even "executable specification." As Martin Fowler wrote, "never in the field of software engineering has so much been owed by so many to so few lines of code." I heartily agree with him. Meszaros has written a hefty book on the effective use of xUnit. At nearly 900 pages, it covers almost anything you could ever want to know about xUnit tools and the design rationale behind them, but almost nothing about test-driven development. Some excellent books have already covered that topic [2], but none in enough depth to work out the inner workings and proper usage of xUnit. The book is organized into three parts, following the series' approach [3]. The first 180 pages of the book, "The Narratives," provide a tutorial on effective test automation using xUnit. Later, a 450-page pattern catalog details test strategies, usage patterns, and code idioms associated with xUnit usage. In between these two, the part titled "The Test Smells" describes symptoms that usually indicate some kind of problem in your test code. "The Narratives" delimit the book's scope, introduce some terminology, and basically deal with the goals, philosophy, principles, and strategies used in modern test automation. They describe some xUnit basics, such as the "setup, exercise, verify, and teardown" test execution cycle. Finally, they also address how to test indirect inputs and outputs, by means of "test doubles," and Meszaros gives some advice on testing with databases. In general, this part of the book provides an excellent overview of test automation. However, I did not particularly like the frequent use of forward references to patterns yet to be discussed. In my opinion, that organization is better suited to a Web page than to a technical book, especially if it is intended to be read by software developers who might not be already acquainted with xUnit test automation. The second part of the book, just as in the book by Fowler et al. on refactoring [4], deals with "smells." In other words, it describes symptoms of problems in test code. Although the problems are not necessarily stated, Meszaros thoroughly analyzes their potential impact, probable causes, and potential solutions. You have probably experienced some smells yourself, and you will recognize them as you plunge into Meszaros' lighthearted vocabulary. This is the shorter but more enjoyable part of the book, where you will find recommendations on making obscure tests more readable, avoiding fragile tests due to interface sensitivity, and not playing "assertion roulette" to figure out who the "mystery guest" is (a slightly improved version of printf debugging). The third part of the book, intended as a reference, contains a detailed pattern catalog. Each pattern description follows a practical format that includes "How It Works" and "When to Use It" sections, some implementation and refactoring notes, and code examples (mostly written in Java, but also in C#, Ruby, and C++). This catalog blends xUnit usage patterns with sound design principles and information that you might only need if you decide to port xUnit to new programming platforms. I particularly liked the patterns devoted to test doubles and design-for-testability techniques. Meszaros discusses usage and construction issues for test stubs, test spies, mock objects, and fake objects. He also addresses the use of dependency injection, dependency lookup, test-specific subclasses, humble objects, and test hooks as "the last resort." Meszaros promotes the effective use of xUnit frameworks for making unit tests more maintainable just by applying the same design principles you would apply to production code. His (painstaking) thoroughness, however, makes this book lengthier and more verbose than necessary, and stand-alone pattern descriptions become somewhat repetitive. Even though its comparison, in the foreword, with the landmark Gang of Four book [5] seems a bit of a stretch, it must be acknowledged that this book is a good reference for developers interested in xUnit tools. The problem is that beginners should probably start somewhere else [2], while much of the material will seem too obvious to experienced xUnit users. Meszaros' advice is sound, and you will also find valuable comments on dealing with legacy code, although better alternatives exist for that, also [6]. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Recommendations