[Tutorial] Dirty Tests and How To Clean Them


We write tests and code for other people. Tests are code too, and both should be clean.
As a clean code fanatic, I see it as a personal mission to go around preaching how powerful clean code is.

But unfortunately, it seems that test code is not considered “real code”, and therefore is not considered “dirty”.

In this session, we’ll talk about concrete examples of anti-patterns in tests, and how to clean them up. We’ll see how clean code principles apply directly to tests. And that’s true for all tests – from unit to end-to-end, and regardless of who writes them – developers and testers. We’ll see those in action.

“Clean code looks like it was written by someone who cares.”, said Michael Feathers. Test code may even be more important to write cleanly for that reason


1. Bring your laptop with an IDE installed. Exercises are in JS/TS, Java, Python or C#.
2. Download the code from https://link.testingil.com/dirty-tests

Key Takeaways:

  • What makes code clean
  • How do clean code principles apply to tests
  • Code smells in tests
  • Refactoring test code