<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-5127857.post8193027322426245685..comments</id><updated>2007-08-28T09:10:32.162+02:00</updated><title type='text'>Comments on Asgeir S. Nilsen tenker litt: How do you achieve 100% test coverage?</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.asgeirnilsen.com/feeds/8193027322426245685/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html'/><author><name>Asgeir S. Nilsen</name><uri>http://www.blogger.com/profile/09990435798930983334</uri><email>asgeirn@gmail.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5127857.post-4241527528039616548</id><published>2007-08-28T09:10:32.162+02:00</published><updated>2007-08-28T09:10:32.162+02:00</updated><title type='text'>Asgeir, thanks for your reply, I'll examine resour...</title><content type='html'>Asgeir, thanks for your reply, I'll examine resources you supposed. &lt;BR/&gt;&lt;BR/&gt;Still my question is a bit different. Say, I'm implementing a custom component: a translucent button.&lt;BR/&gt;&lt;BR/&gt;I can easily evaluate that button is _actually_ translucent just looking at the interface. But how am I supposed to check that automatically within the unit test?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/4241527528039616548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/4241527528039616548'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1188285032162#c4241527528039616548' title=''/><author><name>Juriy</name><uri>http://www.blogger.com/profile/14989735503265608544</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5127857.post-2683440528839385234</id><published>2007-08-27T12:04:34.155+02:00</published><updated>2007-08-27T12:04:34.155+02:00</updated><title type='text'>Dushan,Thanks!When you design test code, you shoul...</title><content type='html'>Dushan,&lt;BR/&gt;&lt;BR/&gt;Thanks!&lt;BR/&gt;&lt;BR/&gt;When you design test code, you should be as thoughtful and considerate as when you design production code.  All the practices of good design apply to test code as well.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/2683440528839385234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/2683440528839385234'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1188209074155#c2683440528839385234' title=''/><author><name>Asgeir S. Nilsen</name><uri>http://www.blogger.com/profile/09990435798930983334</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08959582694896526640'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5127857.post-2773660959754373222</id><published>2007-08-27T10:09:46.034+02:00</published><updated>2007-08-27T10:09:46.034+02:00</updated><title type='text'>Nice post!Just remember that 100% coverage does no...</title><content type='html'>Nice post!&lt;BR/&gt;&lt;BR/&gt;Just remember that 100% coverage does not necessarily mean that the code is well written and 100% correct.&lt;BR/&gt;&lt;BR/&gt;Code coverage only indicates the percentage of code that was &lt;B&gt;exercised&lt;/B&gt; during the test run.&lt;BR/&gt;&lt;BR/&gt;&lt;B&gt;covered != tested&lt;/B&gt;&lt;BR/&gt;&lt;BR/&gt;To make it fully (100%) tested one would need to write tests that cover edge cases as well as the common scenarios. This would usually involve multiple runs over the same code paths. Code coverage can definitely help here. I would only use it as an aiding tool to writing tests, not as an indicator of test quality.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/2773660959754373222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/2773660959754373222'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1188202186034#c2773660959754373222' title=''/><author><name>Dushan Hanuska</name><uri>http://www.blogger.com/profile/11568089987006666223</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5127857.post-1264255981304184746</id><published>2007-08-27T09:26:09.601+02:00</published><updated>2007-08-27T09:26:09.601+02:00</updated><title type='text'>juriy,In general when driving your development thr...</title><content type='html'>juriy,&lt;BR/&gt;&lt;BR/&gt;In general when driving your development through tests, you write tests for the code you intend to implement.  Take a look at the &lt;A HREF="http://en.wikipedia.org/wiki/Test_Driven_Development#Test-Driven_Development_Cycle" REL="nofollow"&gt;Test Driven Development Cycle&lt;/A&gt;.&lt;BR/&gt;&lt;BR/&gt;You should also be very specific on what you are testing, and even more specific on what you are &lt;I&gt;not&lt;/I&gt; testing.  When designing Swing components, you write tests for that component, and not Swing itself.&lt;BR/&gt;&lt;BR/&gt;When writing a GUI using swing, you test your &lt;I&gt;use&lt;/I&gt; of the Swing API, and not Swing itself.  As Stephan mentioned, Jemmy can be of help here.&lt;BR/&gt;&lt;BR/&gt;When unit testing your DB code, you are not testing the JDBC driver or the database implementation.  In-memory databases or mock JDBC drivers can help, but also mocking the database access API you are using.&lt;BR/&gt;&lt;BR/&gt;I use Spring JDBC for one project, and mock out the JdbcOperations and SimpleJdbcOperations interfaces using EasyMock.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/1264255981304184746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/1264255981304184746'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1188199569601#c1264255981304184746' title=''/><author><name>Asgeir S. Nilsen</name><uri>http://www.blogger.com/profile/09990435798930983334</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08959582694896526640'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5127857.post-5193936095049272810</id><published>2007-08-27T08:40:34.167+02:00</published><updated>2007-08-27T08:40:34.167+02:00</updated><title type='text'>Nice post, thanks.I'm new to a TDD, still I feel I...</title><content type='html'>Nice post, thanks.&lt;BR/&gt;&lt;BR/&gt;I'm new to a TDD, still I feel I need to implement this approach in my project.&lt;BR/&gt;&lt;BR/&gt;I've got a question: is it always possible to achieve 100% coverage? For example, if I'm designing or customizing swing component, what should I test?&lt;BR/&gt;&lt;BR/&gt;Speaking about swing and UI, what approaches can you recommend to test those?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/5193936095049272810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/5193936095049272810'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1188196834167#c5193936095049272810' title=''/><author><name>Juriy</name><uri>http://www.blogger.com/profile/14989735503265608544</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5127857.post-3526264479246249366</id><published>2007-08-27T08:02:42.037+02:00</published><updated>2007-08-27T08:02:42.037+02:00</updated><title type='text'>Reaching 100% test coverage is possible, but seldo...</title><content type='html'>Reaching 100% test coverage is possible, but seldom desirable. &lt;BR/&gt;&lt;BR/&gt;The hardest code to reach is certain methods in your Exceptions and every catch clause in your try/catch constructs. Letting yout mocks throw exceptions help here.&lt;BR/&gt;&lt;BR/&gt;Parts of your GUI layer (Swing/Web) can be hard to cover too, as can be your DB code.&lt;BR/&gt;&lt;BR/&gt;I think desired test coverage depends on the project and should range between 70 and 95 %.&lt;BR/&gt;Below 70 and your not testing every important aspect, above 95 and your putting to much energy into testing.&lt;BR/&gt;&lt;BR/&gt;Some tips for testing though: HSQL can help with DB testing, the automatic 'sa' user and the automatic DB creation on the fly in memory make it easier. Wiser SMPT helps with mail testing, Apache virtual file system helps with testing the reading and writing of files (e.g. configuration). Jemmy together with the view/editor patterns helps to reach high coverage for Swing.&lt;BR/&gt;&lt;BR/&gt;Peace&lt;BR/&gt;-stephan&lt;BR/&gt;&lt;BR/&gt;-- &lt;BR/&gt;Stephan Schmidt :: stephan@reposita.org&lt;BR/&gt;Reposita Open Source - Monitor your software development&lt;BR/&gt;http://www.reposita.org &lt;BR/&gt;Blog at http://stephan.reposita.org - No signal. No noise.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/3526264479246249366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/3526264479246249366'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1188194562037#c3526264479246249366' title=''/><author><name>Stephan</name><uri>http://www.blogger.com/profile/03845125686370893937</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5127857.post-1890263740371683793</id><published>2007-08-24T22:30:25.485+02:00</published><updated>2007-08-24T22:30:25.485+02:00</updated><title type='text'>Andres, thanks for your feedback and the link.In a...</title><content type='html'>Andres, thanks for your feedback and the link.&lt;BR/&gt;&lt;BR/&gt;In a perfect world where you get to start from scratch and apply TDD principles from day one, code coverage should never be an issue.&lt;BR/&gt;&lt;BR/&gt;However, if you are introducing TDD later in a project or is new to the methodology, using coverage to measure your progress and the state of your tests is very useful.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/1890263740371683793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/1890263740371683793'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1187987425485#c1890263740371683793' title=''/><author><name>Asgeir S. Nilsen</name><uri>http://www.blogger.com/profile/09990435798930983334</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08959582694896526640'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5127857.post-6006773374804705669</id><published>2007-08-24T17:06:09.966+02:00</published><updated>2007-08-24T17:06:09.966+02:00</updated><title type='text'>Well, following TDD to the letter (very hard to do...</title><content type='html'>Well, following TDD to the letter (very hard to do at first) you will always have 100% coverage because not a single line of production code should be written that doesn't respond a question asked by the test code. Meaning that if you follow TDD and have less than 100% coverage you are doing more than needed, effectively not applying DRY or YAGNI. And remember that 100% coverage is not an useful metric in itself, please check Andy's blog for more pointers (http://thediscoblog.com) =)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/6006773374804705669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127857/8193027322426245685/comments/default/6006773374804705669'/><link rel='alternate' type='text/html' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html?showComment=1187967969966#c6006773374804705669' title=''/><author><name>Andres Almiray</name><uri>http://www.blogger.com/profile/10710950259740699258</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.asgeirnilsen.com/2007/08/how-do-you-achieve-100-test-coverage.html' ref='tag:blogger.com,1999:blog-5127857.post-8193027322426245685' source='http://www.blogger.com/feeds/5127857/posts/default/8193027322426245685' type='text/html'/></entry></feed>