What are Effective Tests?

At the very heart of Continuous Integration and Continuous Confidence, is the automated test. Why do we write a test? If for whatever reason we write a test just to pass, then we are doing it wrong. Let's explore that for a moment.

Superfluous Testing

When we write a test, do we test a getter and a setter? If we answer yes to this question, then let's ask: why, followed by do we have to? Now, these questions need to be answered by each organization, as each requirement is different, but we want to look at something different. We want confidence in our code, and in our release. If we were to draw a line from left to right and say on the left is 0 confidence and on the right is 100% confidence, how much confidence do you gain by testing that a better or a setter worked? Put another way, would we ever write a test that simply returned true?

Now, there are some getters or setters that have logic in them, points where decisions are made and a code bran is taken. That's ok, we test those. 

Test The Changes

When we make changes to the code, the simple way of gaining confidence, is writing a test around those changes and that is it. As we write automated tests, we can guarantee and prove that the code is behaving the way it should. What we don't need are a lot of tests that never fail! We need tests that find problems and tell us when there is a problem.

Ultimately, effective tests are tests that test one thing. Tests that are precise and not convoluted. What we need to understand is that with every layer we introduce between our test and the code it is testing, like an integration test, the less confidence we gain from that test. We may be missing a code path that we weren't expecting. This is where we can gain the most effective confidence in our builds: write better unit tests. Write more effective tests, tests that will fail when they should.

Comments

Popular posts from this blog

Not All CI Solutions Are Created Equal

Stop Talking About Continuous Integration

Legacy Code: What to do About it