Learn how to create effective and maintainable test contexts that help guide other team members rather than acting as a barrier. Keep your contexts focused on the relevant details through the use of the Object Mother and Object Builder patterns.
In this course, you'll see a demonstration of a typical hand-built test context, and the factors that make it brittle and hard to maintain. By using software principles we're all familiar with, and some patterns we may not have seen before, we can create contexts that remain focused on the information most important to understanding what the tests are trying to tell your team. We'll start with general principles, and then move into the Object Mother pattern, a common approach to extracting test context creation tasks. From there, we'll move into the Object Builder pattern, a more modern and expressive evolution of the Object Mother. Finally, you'll see how to use Roslyn-based C# scripts to generate the tedious parts of the Object Builder pattern, so that you can get back to the interesting stuff. When you’re finished with this course, you will have an appreciation for what makes for a good test context, and the skills to apply this knowledge to your current and future projects.
Course Overview Hello. I'm Mel Grubb, and welcome to my course Creating Maintainable Contexts for Automated Testing. I'm a software developer from Columbus, Ohio focused on code quality and developer productivity. As an industry, we've all agreed that tests are vitally important to the longevity and maintainability of our code, but often the simplest of changes can cause an avalanche of broken tests, pulling us out of our groove to wade through complicated test contexts that we didn't write and may not fully understand. In this course, we're going to explore ways to factor out commonalities from the test contexts using the Object Mother and Object Builder patterns so that you can clean the clutter from your contexts and let your tests focus on what's important. I'll even show you how to automatically generate the majority of the Builder's code so that they stay up to date as your project evolves and you can get back to working on the interesting stuff. This is an intermediate testing course so you should be familiar with C#, MVC, and testing frameworks such as NUnit. By the end of the course, you'll have a toolkit and the know-how to write tests that clearly communicate their intent to other developers on your team including future you. I hope you'll join me in my course, Creating Maintainable Contexts for Automating Testing, at Pluralsight.