...

/

Reliable Tests

Reliable Tests

Learn how to write reliable tests that remain useful as the system develops.

Software applications are in a constant state of change. Not only do we build new features, but we also fix bugs and refactor code where we see an opportunity for improvement. If our application is successful, the business will grow, and our project has to evolve to meet increasing demands. Often, a piece of software will develop into a product vastly different from the original proof of concept.

As our system grows, our tests must grow too. We’ll need to write more tests to cover new features and update existing tests to reflect changes in the code base. We’ll inevitably need to update tests, so what does it mean for a test suite to be reliable?

The open-closed principle

The open-closed principle states that our classes should be open to extension but closed to modification.

Open to extension

This means we can add functionality by adding new objects or classes. We build up our feature using composition, which means combining multiple objects. For example, we wrote a reporter class that saves summary data to the ...