Testability is Falsifiability

An entry about tdd Publication date 14. July 2008 14:20

The other day, I was thinking about the way I write unit tests, and how my approach differs depending on when I write the tests. What I came to realise, is that writing the test after the fact makes me biased – in fact, it changes my whole incentive for writing the test. The code is done; now all I want is to bag another passing test to put up on my digital trophy shelf (okay, a slightly artistic exaggeration there :p). Famous philosopher of science, Sir Karl Popper, said it best in his paper Science as Falsification: “It is easy to obtain confirmations, or verifications, for nearly every theory - if we look for confirmations.”

One of the tenets of TDD is that when writing a test, it should initially fail. If you follow this rule, then instead of a green light being the “proof” that the test passes, the proof (I say proof; I mean confidence) becomes the act of making the test pass. This follows the scientific concept of Falsifiability, which aforementioned philosopher Popper came up with. In the same paper quoted above, he also writes that “every genuine test of a theory is an attempt to falsify it, or to refute it. Testability is falsifiability (…) Confirming evidence should not count except when it is the result of a genuine test of the theory; and this means that it can be presented as a serious but unsuccessful attempt to falsify the theory.”

Food for thought when you write your next test, anyway :)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.

NDC 2010

The conference to attend this summer happens June 16th-18th in Oslo, Norway. Are you going? Be sure to catch my talk on AOP while you're there!

 

Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS