Test Refactoring Workshop - Improve Your Unit & Component Tests!
High-quality automated unit tests are one of the key development practices that enable incremental development and delivery of software. xUnit is the generic name given to the family of tools/frameworks used by developers when developing automated unit tests. JUnit, NUnit, MsTest and CppUnit are some of the better-known members of the family.
This 1-day workshop provides the participants with a vocabulary of test smells and patterns with which to elevate their craft when writing or refactoring test code. These smells give them a way to reason about the quality of their test code. The reusable test code design patterns can be used to eliminate the smells. The emphasis will be on refactoring tests to make them easier to understand and maintain.
The workshop introduces a systematic way to identify the test conditions the software needs to handle and how to prepare tests that clearly describe those test conditions in a human-readable way so that the tests can act as effective documentation of what the software should do and what it’s design should be.
Outline/Structure of the Workshop
- Introduction & Terminology
- Summary of Test Conditions
- Refactoring Tests to Improve Readability of Assertions
- Refactoring Tests to Improve Readability of Fixture Setup
- Refactoring Code to Make it More Testable
- Describe functionality in terms of test conditions
- Recognize key test smells that indicate hard-to-understand or fragile tests
- Refactor legacy tests to clearly describe the test condition being verified
- Write new tests that clearly describe the test condition being verified
- Write tests that are easy to understand even when using Stubs, Mocks, and Spies
- Improve the testability of code through refactoring
Software developers and test automation engineers
Prerequisites for Attendees
All participants should bring laptops with a software development environment installed. I will provide sample code in Java (Eclipse) and C# (Visual Studio + ReSharper + NUnit) to be used in the exercises. Participants may also bring their own code to improve during the exercises.
Please download the student's package containing the exercises from:
Instructions for the Exercises (Mandatory): http://india2018workshop-instructions.xunittraining.com/
And pick one of the following based on your language preferences:
Exercises in C#: http://india2018workshop-csharp.xunittraining.com/
Exercises in Java: http://india2018workshop-java.xunittraining.com/
Results in Java: http://india2018workshop-java-results.xunittraining.com/
Results in C#: http://india2018workshop-csharp-results.xunittraining.com/