You are here

Refactoring JUnit Tests

Note: There are prerequisites for attending this workshop. Please see the prerequisites section.

Code that grows over time without refactoring can get quite messy and hard to test. The same applies for to test code, and curiously, they often appear together. Not always is it possible to fix the design problems first, creating a need to write clean tests for hard to test code.

In this workshop, participants will learn some techniques to clean up messy JUnit tests to make them more readable and easier to change.

After a short introduction and an example refactoring, participants will work in pairs to refactor some example unit tests and learn how to write better ones from scratch.

Key takeaways: 

create complex objects easily with the builder patternuse hamcrest matchers to improve your assertionsdiscover the power of JUnit rules


Please install the latest IntelliJ Community edition ( which is available for Mac, Windows and Linux, and have Java and JUnit running from within this.