0 Replies Latest reply on Apr 24, 2012 10:44 PM by dan.j.allen

    Code coverage is not about completeness

    dan.j.allen

      This thought-provoking entry about Test Coverage by Martin Fowler, which Bartosz pointed out to me, begins by challenging the mainstream thinking about code coverage and arrives at the very essence of why we have tests and how many we should write.

       

      There are two key points from this entry that align closely with the Arquillian philosophy:

       

      • Tests (in particular real tests) help reveal areas of the code that are untested or brittle (and therefore will fail at some point in production)
      • You should focus on writing meaningful tests

       

      When you write a test, you don't want it to simply tell you what you want to hear, but rather what is true. In other words, you want it to give you good news only if there is no bad news. Martin summarizes this point nicely with this quote-worthly phrase:

       

      testing requires thoughtfulness

       

      Amen, brother.

       

      The same goes for code coverage. What you want to look at is where coverage is missing, especially the BIG gaps. Be thoughtful when analyzing the coverage metrics and deciding where to invest time in that next meaningful test.