TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Visualize code coverage as you write your code

2 点作者 justinlilly大约 10 年前

1 comment

dalke大约 10 年前
&gt; If you follow TDD, you ensure the line of code is covered by writing the test first, ensuring it fails, then writing the line that makes it pass.<p>This isn&#x27;t quite true. There are two ways to lose line coverage. The first is if new code duplicates a case that was previous caught elsewhere. For example, suppose current code handles n&gt;=0, with a special where n=0 returns 0, and the new code handles n&lt;=0 by returning 0.<p>It&#x27;s not always clear when new code shadows the old code path, leaving it with under 100% coverage.<p>The other way is through refactoring. My usual example is to replace string search implementation using the naive O(n*m) algorithm with the KMP algorithm, keeping the API unchanged. The KMP machinery is more complicated, and it&#x27;s unlikely that the tests used to drive the naive implementation will be enough to validate the refactor.<p>Following the &quot;fear-driven development&quot; methodology means adding more test until you&#x27;re confident the refactor was valid. But this is &quot;test last&quot;, and not part of TDD.<p>I&#x27;m much more an FDD practitioner than I am a TDD one. :) And the idea of live code coverage sounds great to me.