{"id":34,"date":"2009-03-02T09:36:10","date_gmt":"2009-03-02T08:36:10","guid":{"rendered":"http:\/\/blog.eweibel.net\/?p=34"},"modified":"2009-03-02T09:37:49","modified_gmt":"2009-03-02T08:37:49","slug":"is-100-code-coverage-reasonable","status":"publish","type":"post","link":"https:\/\/blog.eweibel.net\/?p=34","title":{"rendered":"Are 100% code coverage reasonable?"},"content":{"rendered":"<p>When you use a code coverage tool one of the first question is what is a good code coverage. Recently I listened to different podcasts (<a href=\"http:\/\/blog.stackoverflow.com\/\">stackoverflow<\/a>, <a href=\"http:\/\/www.hanselman.com\/blog\/\">scott hanselman<\/a>) where they discuss this topic. I wasn&#8217;t really surprised that there wasn&#8217;t one unique opinion.<br \/>One opinion was that 100% is a good number, an other opinion was that for non-failing code it doesn&#8217;t make sense to build a test, so 100% isn&#8217;t a good number for most of the projects.<br \/>The last opinion sounds not that bad, but for which code it doesn&#8217;t make sense to build unit tests?<br \/>Here is a (not complete) list of code elements for which I wouldn&#8217;t build a unit-test:<\/p>\n<ul>\n<li>Properties (.Net)\n<li>Getters (Java)\n<li>Setters (Java)\n<li>Primitive Constructors (no chaining, no big logic in it)\n<li>Services (which just delegate to the business logic)\n<li>GUI (Views)\n<li>Data Access (do not test a framework)\n<li>Services of another component or another application (do not test a library or another application)\n<li>Any Generated Code (do not test a tool, in this case a code generator)<\/li>\n<\/ul>\n<p>Is there a code element or type which I forget?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you use a code coverage tool one of the first question is what is a good code coverage. Recently I listened to different podcasts (stackoverflow, scott hanselman) where they discuss this topic. I wasn&#8217;t really surprised that there wasn&#8217;t one unique opinion.One opinion was that 100% is a good number, an other opinion was that for non-failing code it doesn&#8217;t make sense to build a test, so 100% isn&#8217;t a good number for most of the projects.The last opinion&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/blog.eweibel.net\/?p=34\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,10],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-software-architecture","category-testing"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/plOV9-y","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":200,"url":"https:\/\/blog.eweibel.net\/?p=200","url_meta":{"origin":34,"position":0},"title":"How to structure code in an unit test","author":"Patrick","date":"14. Jun 2009","format":false,"excerpt":"When you create your unit tests for a method in the SUT (software under test) you will ask yourself how to structure the code in the test method.I saw two kind of syntaxes which help to structure the code in a unit test method (well, actually there are at least\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":942,"url":"https:\/\/blog.eweibel.net\/?p=942","url_meta":{"origin":34,"position":1},"title":"Enums and inheritance in .Net","author":"Patrick","date":"9. Feb 2011","format":false,"excerpt":"In one of my current projects I had the following code (I simplified the code a bit): public string ConnectionString { get { switch(this.Importer) { case Importer.SqlServer: return \"Server=localhost;Database=Northwind\"; case Importer.SqlServerOleDb: return\"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind\"; default: throw new NotSupportedException( string.Format(\"Importer {0} is not supported yet.\", this.Importer)); } } } After running\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"CodeCoverage","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":303,"url":"https:\/\/blog.eweibel.net\/?p=303","url_meta":{"origin":34,"position":2},"title":"From NUnit to MSTest","author":"Patrick","date":"30. Jun 2009","format":false,"excerpt":"Last week I migrated several projects from NUnit to MSTest. The developers use the Developer version of Microsoft Visual Studio Team System, so they have integrated unit-test support for MSTest. In this post I show you all the problems and work I had to migrate the tests from NUnit to\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":718,"url":"https:\/\/blog.eweibel.net\/?p=718","url_meta":{"origin":34,"position":3},"title":"Do frameworks kill design skills?","author":"Patrick","date":"8. Feb 2011","format":false,"excerpt":"Software design is one of the most important skills a software engineer should have. But what is software design exactly? If you search for a definition you find something like this: Software design is a process of problem-solving and planning for a software solution. After the purpose and specifications of\u2026","rel":"","context":"In &quot;Design patterns&quot;","block_context":{"text":"Design patterns","link":"https:\/\/blog.eweibel.net\/?cat=3"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/image_thumb11.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1086,"url":"https:\/\/blog.eweibel.net\/?p=1086","url_meta":{"origin":34,"position":4},"title":"Grooming your code base","author":"Patrick","date":"1. Sep 2011","format":false,"excerpt":"When you're doing Test Driven Development (TDD), it's in the process: Red-Green-Refactor. Refactoring doesn't only mean to improve your new code, it is also important to make your existing code nicer. If you are a .NET Developer, then you should have the Visual Studio Add-on ReSharper. With this tool you\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"Fotolia_32643902_S","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/Fotolia_32643902_S_thumb1.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":76,"url":"https:\/\/blog.eweibel.net\/?p=76","url_meta":{"origin":34,"position":5},"title":"Code generation for unit testing","author":"Patrick","date":"10. Mar 2009","format":false,"excerpt":"There exists a project at Microsoft which generate unit tests based of source code. The name of this interesting project is Pex.At the first time when I heard about this project I was skeptical. Where's the value of generated tests? Doesn't it break the \"test first\" approach? After I saw\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":11,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions\/53"}],"wp:attachment":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}