Monday, November 21, 2011

Tests feedback

14:00h - 15:15h Maximizing learning from test feedback. 

Learning = detection + correction } error = what I want - what I got

Learning is detection plus correction. The error is the gap between what I want and what I get.

It is difficult to find where the code breaks, when it is not clear what we want as a result of a piece of code. The tests needs to clearly express what we want the code to do. It is necessary as well to check what is the value of each test, so we can remove useless and duplicated tests.  

Testing is not optional. It is not like a car with or without airbag. It is the wrong approach to leave testing to the end and add it as an optional part. TDD should be focused on testing behavior, this should allow to understand the goal and value of the test. It is required to have code and tests with clear separation of responsibilities. This helps to get clean feedback of the test results and helps to easily find the mismatches.

Learning from the test results is to find mismatches. Once we have the mismatch we need to do two things. First fix the behavior to get it as we want. And second check ideas and get a clear understanding about why there was a mismatch. Was it a bug? So why there was that bug in the code. Take some plan or actions to avoid similar situations. The second part is the most important one, because drives the project with 'kaizen' style of continuous improvement. This part will required rethinking of ideas and drop false assumptions to discover the real reasons of the mismatch.

While developing code, it is better to commit small steps while going to the final result. It is an evolution of the code and the tests. Google wave can help to build that evolution of getting the story right when defining new features.

When trying to learn and understand about a mismatch between what we want and what we have. It is necessary to get metrics in order to support decisions. Do not make assumptions. That is why tests needs to report as much metrics as possible.

Posted by Marc Andreu Fernàndez.

No comments: