<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/1.5.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: The Illusion Of High Test Coverage</title>
	<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/</link>
	<description>Lidor Wyssocky's Blog on Optimizing Software Development</description>
	<pubDate>Fri, 25 Jul 2008 10:46:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.2</generator>

	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: Dave Nicolette</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-1246</link>
		<pubDate>Fri, 11 Aug 2006 14:37:41 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-1246</guid>
					<description>It's easy to be fooled into thinking you're testing everything that needs to be tested when a coverage tool tells you you've hit 100% coverage. All it really means is that you're exercising every line of code at least once. There may be many conditions that cause execution of a given section of code. I used to think it was &lt;a href=&quot;http://www.davenicolette.net/agile/index.blog?start=1119500401&amp;#38;topic_id=1020305&quot; rel=&quot;nofollow&quot;&gt;okay to write unit tests after the fact&lt;/a&gt;, but since then I've become convinced that writing tests first helps avoid a multitude of problems. One problem it helps avoid is the false sense of security you can get from a coverage tool. If you've thought through the tests that need to be done before you write the code, you can't be lulled into writing tests merely to nudge the coverage toward 100%. You have to think about how to tell whether the requirements have been met. Once you have a set of tests that tells you the truth about that, you're in good shape. The &amp;#34;red&amp;#34; phase of the TDD cycle doesn't just mean that a test fails; it has to fail for the right reason. Otherwise, it won't pass for the right reason, either, and then where will you be? Seems to me the test suite doesn't tell you anything useful, then. 

Lidor's example about the id string is a case in point. In the example, you write the code first and then you forget to write all the relevant test cases. If you wrote the tests first, you'd be compelled to think through all the necessary test cases before you could be distracted by the behavior of any actual code. There's a natural tendency to write tests that prove the code &amp;#34;does what it does.&amp;#34; Writing the tests first is a way to short-circuit that natural tendency and force you to think things through. Maybe that's more about psychology than methodology, but I've seen it happen enough times to accept it as reality.

Another issue is that people who aren't very mature in their use of TDD sometimes worry a lot about seeing red. They assume red means &amp;#34;bad.&amp;#34; They may take shortcuts in order to be sure they see green. Sometimes they end up coding to satisfy the coverage tool, because it's an easy way to block out the red. That can lead to an inadequate test suite. Someone can make a change that breaks something, but the test suite doesn't fail. The thing is, red is your friend when it shows up for the right reasons. You want to have tests fail when the code starts generating different results, because it's the easiest mechanism you have for detecting defects and notifying you of them. Assuming you're working with TDD and continuous integration, a failed build doesn't mean you've done bad work, it's just an indication that you need to investigate what changed. If you've just written the minimal tests necessary to satisfy a coverage tool, you could easily miss a case like that. A defect could go undetected for some time, and we all know that the longer a defect goes undetected, the more expensive it's likely to be to fix it.</description>
		<content:encoded><![CDATA[	<p>It&#8217;s easy to be fooled into thinking you&#8217;re testing everything that needs to be tested when a coverage tool tells you you&#8217;ve hit 100% coverage. All it really means is that you&#8217;re exercising every line of code at least once. There may be many conditions that cause execution of a given section of code. I used to think it was <a href="http://www.davenicolette.net/agile/index.blog?start=1119500401&amp;topic_id=1020305" rel="nofollow">okay to write unit tests after the fact</a>, but since then I&#8217;ve become convinced that writing tests first helps avoid a multitude of problems. One problem it helps avoid is the false sense of security you can get from a coverage tool. If you&#8217;ve thought through the tests that need to be done before you write the code, you can&#8217;t be lulled into writing tests merely to nudge the coverage toward 100%. You have to think about how to tell whether the requirements have been met. Once you have a set of tests that tells you the truth about that, you&#8217;re in good shape. The &quot;red&quot; phase of the TDD cycle doesn&#8217;t just mean that a test fails; it has to fail for the right reason. Otherwise, it won&#8217;t pass for the right reason, either, and then where will you be? Seems to me the test suite doesn&#8217;t tell you anything useful, then. </p>
	<p>Lidor&#8217;s example about the id string is a case in point. In the example, you write the code first and then you forget to write all the relevant test cases. If you wrote the tests first, you&#8217;d be compelled to think through all the necessary test cases before you could be distracted by the behavior of any actual code. There&#8217;s a natural tendency to write tests that prove the code &quot;does what it does.&quot; Writing the tests first is a way to short-circuit that natural tendency and force you to think things through. Maybe that&#8217;s more about psychology than methodology, but I&#8217;ve seen it happen enough times to accept it as reality.</p>
	<p>Another issue is that people who aren&#8217;t very mature in their use of TDD sometimes worry a lot about seeing red. They assume red means &quot;bad.&quot; They may take shortcuts in order to be sure they see green. Sometimes they end up coding to satisfy the coverage tool, because it&#8217;s an easy way to block out the red. That can lead to an inadequate test suite. Someone can make a change that breaks something, but the test suite doesn&#8217;t fail. The thing is, red is your friend when it shows up for the right reasons. You want to have tests fail when the code starts generating different results, because it&#8217;s the easiest mechanism you have for detecting defects and notifying you of them. Assuming you&#8217;re working with TDD and continuous integration, a failed build doesn&#8217;t mean you&#8217;ve done bad work, it&#8217;s just an indication that you need to investigate what changed. If you&#8217;ve just written the minimal tests necessary to satisfy a coverage tool, you could easily miss a case like that. A defect could go undetected for some time, and we all know that the longer a defect goes undetected, the more expensive it&#8217;s likely to be to fix it.
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: engtech</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-948</link>
		<pubDate>Fri, 14 Jul 2006 02:12:19 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-948</guid>
					<description>Coverage metrics are all misleading, but they are better than the alternative.

In terms of hardware verification (where having a bug can mean a $1 million respin) there are a couple of approaches used.

- code coverage, but that doesn't catch combinations of sequences
- separate team writing black box tests to the spec, and gray box tests to the design
- constraint random with functional coverage (track all of the requirements, and run random combinations of data to hit the majority and then aim for the smaller remaining percentage)
- formal verification where you have software that formally asserts that a condition will always hold true for all possible combinations to a certain depth</description>
		<content:encoded><![CDATA[	<p>Coverage metrics are all misleading, but they are better than the alternative.</p>
	<p>In terms of hardware verification (where having a bug can mean a $1 million respin) there are a couple of approaches used.</p>
	<p>- code coverage, but that doesn&#8217;t catch combinations of sequences<br />
- separate team writing black box tests to the spec, and gray box tests to the design<br />
- constraint random with functional coverage (track all of the requirements, and run random combinations of data to hit the majority and then aim for the smaller remaining percentage)<br />
- formal verification where you have software that formally asserts that a condition will always hold true for all possible combinations to a certain depth
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: How I jump to my conclusions &#187; None of the errors found</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-471</link>
		<pubDate>Sat, 03 Jun 2006 07:41:38 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-471</guid>
					<description>[...] Lidor warns about using test coverage metrics as they may create the illusion you are doing well, when you are not. [...]</description>
		<content:encoded><![CDATA[	<p>[&#8230;] Lidor warns about using test coverage metrics as they may create the illusion you are doing well, when you are not. [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: Phill</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-277</link>
		<pubDate>Mon, 15 May 2006 16:09:22 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-277</guid>
					<description>Test coverage seems to come up as some sort of unit test valhalla-builder every once and a while and I've gotten my response down pat:

Imagine a function that divides two numbers and returns the result. You test the arguments 4, and 2 and you've got a 100% coverage. Are you comfortable with that?

That's why 100% coverage is a _good start_.


That said, I do believe it's a good tool in investigating the code to find out where the best bang for your buck is in new unit tests.. Unfortunately, we don't always write our tests first... if we did, code coverage tools would be useless.</description>
		<content:encoded><![CDATA[	<p>Test coverage seems to come up as some sort of unit test valhalla-builder every once and a while and I&#8217;ve gotten my response down pat:</p>
	<p>Imagine a function that divides two numbers and returns the result. You test the arguments 4, and 2 and you&#8217;ve got a 100% coverage. Are you comfortable with that?</p>
	<p>That&#8217;s why 100% coverage is a _good start_.</p>
	<p>That said, I do believe it&#8217;s a good tool in investigating the code to find out where the best bang for your buck is in new unit tests.. Unfortunately, we don&#8217;t always write our tests first&#8230; if we did, code coverage tools would be useless.
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: Harry Nieboer</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-276</link>
		<pubDate>Sun, 14 May 2006 21:16:39 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-276</guid>
					<description>This reminds me of a fine compiler we used at the Nijmegen university some 20 years ago.
If a program compiled fine, the program would show the message:

&quot;None of the errors found&quot; ...</description>
		<content:encoded><![CDATA[	<p>This reminds me of a fine compiler we used at the Nijmegen university some 20 years ago.<br />
If a program compiled fine, the program would show the message:</p>
	<p>&#8220;None of the errors found&#8221; &#8230;
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: Lidor Wyssocky</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-274</link>
		<pubDate>Sun, 14 May 2006 08:28:24 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-274</guid>
					<description>&lt;p&gt;
Hi Shmarmeant&lt;/p&gt;&lt;p&gt;Again, there is no argument about the benefits of code-based test coverage. The point is that trying to get a sense of the quality of your testing suite based solely on test coverage is misleading. You have to analyze the tests and see what's missing (logically). 

&lt;/p&gt;&lt;p&gt;Lidor&lt;/p&gt;</description>
		<content:encoded><![CDATA[	<p>
Hi Shmarmeant</p>
	<p>Again, there is no argument about the benefits of code-based test coverage. The point is that trying to get a sense of the quality of your testing suite based solely on test coverage is misleading. You have to analyze the tests and see what&#8217;s missing (logically). </p>
	<p>Lidor</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: shmarya</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-273</link>
		<pubDate>Sun, 14 May 2006 06:09:05 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-273</guid>
					<description>Test Coverage can also help to identify dead-code which can be removed during a refactoring cycle...</description>
		<content:encoded><![CDATA[	<p>Test Coverage can also help to identify dead-code which can be removed during a refactoring cycle&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: Tom Harris</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-272</link>
		<pubDate>Sat, 13 May 2006 19:06:09 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-272</guid>
					<description>Accordingly, a response to Zuzzu as well:

FIT (for those who haven't, see http://www.artima.com/weblogs/viewpost.jsp?thread=67373), can indeed &quot;spot the ... issue.&quot; What it can't do is tell you what to do about it. Yes, you'll know you missed a test, but neither FIT nor any other tool will tell you how to write the test, or whether you really need to write two or three tests.</description>
		<content:encoded><![CDATA[	<p>Accordingly, a response to Zuzzu as well:</p>
	<p>FIT (for those who haven&#8217;t, see <a href='http://www.artima.com/weblogs/viewpost.jsp?thread=67373' rel='nofollow'>http://www.artima.com/weblogs/viewpost.jsp?thread=67373</a>), can indeed &#8220;spot the &#8230; issue.&#8221; What it can&#8217;t do is tell you what to do about it. Yes, you&#8217;ll know you missed a test, but neither FIT nor any other tool will tell you how to write the test, or whether you really need to write two or three tests.
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: Tom Harris</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-271</link>
		<pubDate>Sat, 13 May 2006 18:59:39 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-271</guid>
					<description>Lidor,

I recently reviewed a co-worker's training session on test coverage, and commented on just this topic. But I would go further, and say it more forcefully. 

Test coverage measures that mark 100% coverage when there's one test for every requirement are sorely misleading. Accepting their numbers as any measure of test set correctness and completeness is just wrong. 

Writing the right number of correct tests for a requirement is the activity of test design, which requires knowledge and experience. Determining whether you've got true test coverage cannot be done by a tool (FIT or otherwise); only by a person. An automated test coverage tool does the following, and no more: it identifies requirements (or code) with zero test coverage so that you can design tests for them.

 - Tom</description>
		<content:encoded><![CDATA[	<p>Lidor,</p>
	<p>I recently reviewed a co-worker&#8217;s training session on test coverage, and commented on just this topic. But I would go further, and say it more forcefully. </p>
	<p>Test coverage measures that mark 100% coverage when there&#8217;s one test for every requirement are sorely misleading. Accepting their numbers as any measure of test set correctness and completeness is just wrong. </p>
	<p>Writing the right number of correct tests for a requirement is the activity of test design, which requires knowledge and experience. Determining whether you&#8217;ve got true test coverage cannot be done by a tool (FIT or otherwise); only by a person. An automated test coverage tool does the following, and no more: it identifies requirements (or code) with zero test coverage so that you can design tests for them.</p>
	<p> - Tom
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on The Illusion Of High Test Coverage by: Zuzzu</title>
		<link>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-270</link>
		<pubDate>Sat, 13 May 2006 17:56:02 +0000</pubDate>
		<guid>http://blog.qualityaspect.com/2006/05/13/the-illusion-of-high-test-coverage/#comment-270</guid>
					<description>you are right and that's why there are other kind of tests. Taking you example a FIT test written by a tester would have spotted the validation issue at the first run!</description>
		<content:encoded><![CDATA[	<p>you are right and that&#8217;s why there are other kind of tests. Taking you example a FIT test written by a tester would have spotted the validation issue at the first run!
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
