• Nov 9, 2017

I'm always interested in getting the computer to tell me how to tell it what to do more successfully, and, to further that pursuit, I've started taking an interest in code coverage.

If you're not familiar with the term, "code coverage" refers to reporting on which lines of code were actually executed during runtime, most commonly in association with unit tests. Eclipse (and presumably other IDEs) has support for this, and I've decided to give it a shot.

Since I'm starting this out in the context of Domino plugins, there are more wrinkles than in most tutorials. Namely, the test suites I've written run exclusively through Maven instead of the Eclipse UI due to all the Notes environment setup, so I can't just use the normal UI tools to gather the data. Fortunately, Eclipse's EclEmma will work just fine with the output from a Maven project, as long as you configure it properly. I looked around for a while to find the right combination of tools to use, but it ended up being fairly simple to configure basic output that can be consumed in Eclipse's Coverage view.

There are two main additions. First, add the jacoco-maven-plugin to your root project's project.build.plugins block:


In normal cases, that would suffice. However, since the test configuration I have for Notes overrides the argLine property of the Tycho test runner, there's another step - add the tycho.testArgLine property manually into those blocks, such as in the Windows profile:


					<argLine>${tycho.testArgLine} -Dfile.encoding=UTF-8 -Djava.library.path="${notes-program}"</argLine>

Once that's configured, running the test suite via Maven will create a new file in the target folder of the test plugin: jacoco.exec. This file can then be consumed in Eclipse by opening the "Coverage" view:

Eclipse's Show View window

In that view, right click and choose "Import Session..." and point to the data file. Click "Next" and check the projects+source folders from your workspace you're interested in analyzing. When you click "Finish", it'll do two things. First, it'll fill the Coverage view with statistics from your run:

Code Coverage stats

(We have a lot of work to do fleshing out our test suites for this one)

Secondly, it'll start highlighting your code to show you what code is executed, which branches are only partially covered, and which lines are skipped entirely. For example (ignore the sickly color scheme - I need to work on that):

Code Coverage example

This shows how several of the if branches are only tested in one direction, while the "Faces" block is skipped entirely. That also shows some of the trouble with testing XPages-run code: the Tycho environment can't reproduce the XPages environment fully, so some branches aren't testable in that way. I haven't looked into the possibility of gathering similar data from JUnit for XPages, so perhaps that's possible.

For now, though, this will have to do. And, like with these other "code improvement" techniques I've integrated lately, there's a lot of potential tedium - juggling when to write a test to cover some code that will obviously always work just to improve the highlighting vs. just focusing on the low-hanging fruit - but I expect that it will be a nice addition to my workflow over time.

Nov 10, 2017
Sasa Brkic

Great stuff!

We have been using JaCoCo and SonarQube in our projects and are very satisfied with the results. It took some time to properly configure Maven, Tycho and everything else (especially for projects with multiple plugins/test plugins), but we now have everything working in our CI environment. We even get nice code coverage badge on our Gitlab pages :-)

We are not using XPages, so like you, I cannot comment on integrating XPages in this setup.

Nov 27, 2017

I truly delight in concentrate this article. trust that you may do to a great degree great in forthcoming time. I essentially got to this great site online no longer extensive before. Assignment Writing Service | Assignment-Empire

Jan 16, 2018
Sofia Watson

You are always interested in getting the computer to tell me how to tell it what to do more successfully. As a assignment writers i shared my opinion is your first coding step is really impressive and informative too. so i hope you will be shared with us second step.

Jan 22, 2018
Anthony Anson

Programming is very hard for the beginners like Me but when you practice daily then you can able to do something you want and I'm also wanted to be a programmer and want to help with online cheap programming assignment to the students who are facing issues while doing this but anyway Thank you dear for this post. 

Jan 25, 2018
Nida Amber Sheikh

Is this a WordPress plugin? I am looking for WordPress plugin like Yoast because I am creating dissertation writing help website to assist students in their thesis and dissertations.

Jan 26, 2018


Jan 26, 2018
Julia Roberts

I will try this code on my WordPress website.The purpose of this website is to provide low price essay service to the weak students.Maybe this plugin helps to improve the rank of my website on search engines.

Feb 6, 2018
Marlin Wright

This code is relevant to my field and trusts me it is a great support for me to understand the code in real time.  As Inexpensive Essay Assistance Plugin and Eclipse UI understandable for novice students

Feb 6, 2018
Chris Jimmy

Plugins can be created and used for many terms for websites. Plugins are helpful to manage and solve the problems of rush coding. I have used a number of plugins on my own website Dissertation Service to manage it properly.   If you want to install SEO plugins I recommend you to install all in one Seo plugin in Wordpress CMS.  

Feb 19, 2018

Writing computer programs is hard for the tenderfoots like Me yet when you rehearse every day then you can ready to accomplish something you need and I'm additionally needed to be a software engineer and need to help with Assignment Service to the understudies who are confronting issues while doing this yet at any rate Thank you dear for this post.

Feb 19, 2018

You are constantly inspired by getting the PC to guide me how to reveal it more effectively. As an Assignment Services, I imparted my insight is your first coding venture is extremely amazing and instructive as well. so I trust you will be imparted to our second step.

Post New Comment