{"id":1251,"date":"2017-05-18T17:47:04","date_gmt":"2017-05-18T17:47:04","guid":{"rendered":"http:\/\/www.testingdocs.com\/questions\/?p=1251"},"modified":"2024-12-14T04:37:07","modified_gmt":"2024-12-14T04:37:07","slug":"how-to-perform-code-coverage-with-eclipse","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-perform-code-coverage-with-eclipse\/","title":{"rendered":"How to perform code coverage using Eclipse?"},"content":{"rendered":"<h2>How to perform code coverage with Eclipse?<\/h2>\n<p>There are many ways to instrument your test automation code and with many tools. The code coverage tool you pick mostly depends on the programming language. In other words, it depends on the language used to write your automation code.<\/p>\n<h2>Code Coverage Video Tutorial<\/h2>\n<p><iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/9vqG-jgAX00?si=ofOWWXx_3ggyFJgd\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<h2><strong>EclEmma: Java Code Coverage(JaCoCo)<\/strong><\/h2>\n<p>EclEmma is a free coverage tool for Eclipse, available under the Eclipse Public License. The tool is non-invasive. It does not require modifying your project files or any instrumentation set up as such.<\/p>\n<h2><strong>Steps to Install the Plugin<\/strong><\/h2>\n<p>Install EclEmma plugin for Eclipse.<br \/>\nLaunch marketplace from your Eclipse menu select <strong>Help &gt;&gt; Eclipse Marketplace<\/strong>.<br \/>\nSearch for EclEmma and click on the Go button.<br \/>\nHit on Install for EclEmma Java Code Coverage.<br \/>\nFollow the steps and instructions in the installation wizard.<\/p>\n<p>You may need to restart Eclipse after the plugin is installed.<\/p>\n<h2><strong>Code Coverage Configuration<\/strong><\/h2>\n<p>Once you restart Eclipse, in the Coverage window, choose the entries for the code coverage analysis scope as shown below:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-984\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Code-Coverage-Configuration.png\" alt=\"Code Coverage Configuration\" width=\"1003\" height=\"629\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p>The plugin supports many launch types. In this example, I&#8217;m using the TestNG test launch type. You can use for other launch types like Java applications, JUnit test,s etc.<\/p>\n<p>Run the TestNG tests. Alternatively,\u00a0 you can run the tests with the<strong> Coverage As<\/strong> option.<\/p>\n<h2><strong>Coverage View<\/strong><\/h2>\n<p>The Coverage view shows all analyzed Java items as shown below. It can be opened from the Window &gt;&gt; Show View &gt;&gt; Other&#8230; &gt;&gt; Java category menu.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-985\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/CodeCoverage-using-EclEmma-Plugin.png\" alt=\"CodeCoverage using EclEmma Plugin\" width=\"1365\" height=\"718\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p>The tool also supports the export of coverage sessions in many formats, like HTML, XML, CSV, etc.<\/p>\n<h2>Code Coverage Metrics<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.testingdocs.com\/code-coverage-metrics\/\">https:\/\/www.testingdocs.com\/code-coverage-metrics\/<\/a><\/li>\n<\/ul>\n<h2>JaCoCo<\/h2>\n<p>JaCoCo is a code coverage library for Java, created by the EclEmma team.<\/p>\n<ul>\n<li><strong>https:\/\/www.jacoco.org\/jacoco\/trunk\/index.html<\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>How to perform code coverage with Eclipse? There are many ways to instrument your test automation code and with many tools. The code coverage tool you pick mostly depends on the programming language. In other words, it depends on the language used to write your automation code. Code Coverage Video Tutorial &nbsp; EclEmma: Java Code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[22],"class_list":["post-1251","post","type-post","status-publish","format-standard","hentry","category-eclipse","tag-eclipse","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=1251"}],"version-history":[{"count":15,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1251\/revisions"}],"predecessor-version":[{"id":26422,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1251\/revisions\/26422"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=1251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}