Course: Writing Maintainable Unit Tests

Nothing makes a system more flexible than a suite of tests. Nothing.
— Robert C. Martin (Uncle Bob)

Why attend?

Are unit tests causing you pain? Are they constantly failing whenever you make changes to your production code? Do you spend a lot of time fixing them when they break? Are they difficult to set up and run? Do you have a hard time maintaining or structuring your unit test code? Are they causing you headaches from time to time? Are you on the brink of giving up on writing unit tests altogether or have you already done so?

Or do you just want to step up your game and want to learn more about how to write readable and maintainable unit tests?

This course is for experienced software developers who want to improve upon their existing skills in writing unit tests. By the end of this course, students will have gained the knowledge necessary to build loosely coupled, highly maintainable and robust unit tests that are trustworthy and improve the overall code quality of your software applications. The content of this course is based on 15+ years of experience with Test-Driven Development. The knowledge presented in this course is essential for becoming a senior-level software developer or a technical lead.

Course content

  • Why we need automated tests
  • Taxonomy of tests
  • Solitary versus sociable tests
  • The test pyramid
  • State versus behaviour verification
  • Test-Driven Development (TDD)
  • Clean unit tests
  • The DRY principle
  • The Single-Responsibility Principle (SRP)
  • The DAMP principle
  • Other characteristics of maintainable unit tests
  • Arrange, Act, Assert (AAA)
  • AAA per test method
  • Single assert per test
  • Setup / TearDown
  • AAA per test class
  • Assert last principle
  • Naming unit tests
  • Public interfaces
  • Object mother
  • Test data builder
  • State versus behaviour verification (again)
  • Indirect inputs and outputs
  • SUT builder
  • Auto mocking container
  • Fixture object
  • Making clear observations
  • Failing tests
  • Single assert per test
  • Procedural versus object state verification

Prerequisites

Although the examples that are used throughout this course are written in C#, the principles and guidance discussed here are broadly applicable to other platforms and programming environments as well (Java, Python, JavaScript, etc.). Students will be able to universally apply this knowledge throughout the rest of their careers as software developers. Nonetheless, having a good understanding of the following topics will definitely make it easier to pick up the content of this course:

  • A decent understanding of an object-oriented programming language, preferably C# or Java.
  • At the very least some first experiences writing unit tests for production code.
  • Basic or intermediate knowledge of an xUnit test framework.
  • Basic or intermediate knowledge of a mocking framework (Moq, NSubstitute, Rhino Mocks, Mockito, etc.).

Details

Duration 2 full days
Maximum attendees 12
Location Online, on-site or an arranged venue
Availability 2 months notice
Test-Driven Development (TDD) isn’t something that comes naturally. It’s a discipline, like a martial art, and just like in a Kung Fu movie, you need a bad-tempered and unreasonable master to force you to learn the discipline.
— Harry Percival ("Test-Driven Development with Python")

Contact me at infonull@nullprincipal-itnull.be or call +32 496 38 00 82

About

Thank you for visiting my website. I’m a professional software developer since Y2K. A blogger since Y2K+5. Author of Writing Maintainable Unit Tests. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Thinking and learning about all kinds of technologies since forever.

Contact information

(+32) 496 38 00 82

infonull@nullprincipal-itnull.be