Code coverage on rcp application

34 views
Skip to first unread message

geob...@gmail.com

unread,
Jul 6, 2020, 8:48:54 AM7/6/20
to JaCoCo and EclEmma Users
I am using Froglogic's Squish to test an rcp application. For each test case I am looking to use Jacoco's command line interface to gather code coverage exec files at the conclusion of each test case and then merge the files to generate a running cumulative report.  Because I am using an rcp application there is neither a jar file or a singular classfile I can point the following command at:
"java -javaagent:%s/lib/jacocoagent.jar=destfile=path/to/exec -jar jarfile"
How would I prep my application and testcases such that meaningful code coverage reports are generated. Right now when a report is generated from the exec, it reads zero for all categories. An screen capture of this can be seen below.

Capture.PNG


Marc Hoffmann

unread,
Jul 6, 2020, 8:53:58 AM7/6/20
to jac...@googlegroups.com
So how exactly do you start your RCS application without JaCoCo?


<Capture.PNG>



--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/a935375c-ac1a-434c-9c2e-a0d1bdbc7e99o%40googlegroups.com.
<Capture.PNG>

geob...@gmail.com

unread,
Jul 6, 2020, 9:03:32 AM7/6/20
to JaCoCo and EclEmma Users

Capture.PNG

I have attached an image above. This is standard practice in squish. I have designated a. exe file which squish will launch. After doing some reading, I believe it should be launched in a manner similar to that in the following link: https://www.froglogic.com/blog/tip-of-the-week/integrating-java-code-coverage-tools-with-squish-tests/. However, if I were to simply use the .jar file I would not be testing the application that consumers interact with. Is there a way to launch the .exe file while still capturing code coverage?


On Monday, July 6, 2020 at 8:53:58 AM UTC-4, Marc R. Hoffmann wrote:
So how exactly do you start your RCS application without JaCoCo?


On 6. Jul 2020, at 14:48, geob...@gmail.com wrote:

I am using Froglogic's Squish to test an rcp application. For each test case I am looking to use Jacoco's command line interface to gather code coverage exec files at the conclusion of each test case and then merge the files to generate a running cumulative report.  Because I am using an rcp application there is neither a jar file or a singular classfile I can point the following command at:
"java -javaagent:%s/lib/jacocoagent.jar=destfile=path/to/exec -jar jarfile"
How would I prep my application and testcases such that meaningful code coverage reports are generated. Right now when a report is generated from the exec, it reads zero for all categories. An screen capture of this can be seen below.

<Capture.PNG>



--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.

Marc Hoffmann

unread,
Jul 6, 2020, 10:34:30 AM7/6/20
to jac...@googlegroups.com
Hi,

if your exe is a Eclipse RCP launcher you can add JVM arguments like this:

    your.exe -vmargs -javaagent:%s/lib/jacocoagent.jar=destfile=path/to/exec

See Eclipse documentation:


Regards,
-marc






To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/65105762-080f-4058-a3fb-25f59f4ffa32o%40googlegroups.com.
<Capture.PNG>

geob...@gmail.com

unread,
Jul 7, 2020, 12:42:10 AM7/7/20
to JaCoCo and EclEmma Users
To be clear, this should launch the application and create the .exec file, so then when the application is closed the command for html report generation can be executed? In summary, I should navigate to the jacoco-0.8.6/lib/, execute the following command: path/to/my.exe -vmargs -javaagent:%s/lib/jacocoagent.jar=destfile=path/to/exec, then the test case should execute (interacting with application's interface), close the application, and run the command to generate a html code coverage report.

Marc Hoffmann

unread,
Jul 7, 2020, 4:39:41 AM7/7/20
to jac...@googlegroups.com
Correct!

No need to change to JaCoCo installation directory. Just provide the correct path to jacocoagent.jar.


To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/bd50de11-0542-4584-855b-bb679168eadco%40googlegroups.com.

geob...@gmail.com

unread,
Jul 7, 2020, 10:03:37 AM7/7/20
to JaCoCo and EclEmma Users



cmd_out.PNGcmd_out_1.PNGrep.PNGsession.PNG


I have done as you instructed (screenshots of the command prompt arguments and outputs can be seen above). When I run the recommended command ("path\to\GeoWorxSyncGUI.exe -vmargs -javaagent:path/to/lib/jacocoagent.jar=destfile=path/to/cc_rep_1242.exec") the .exec file is created. I ran the execinfo command to ensure that something was happening (the results can be seen in the screenshot above). Once I run the command to generate the html it still reads zero for all classes. Why might this be the case?

Marc Hoffmann

unread,
Jul 7, 2020, 10:40:11 AM7/7/20
to JaCoCo and EclEmma Users
Ok, so you’re collecting execution data. Under the “Sessions” page all classes where data has been collected for are listed. Are your classes listed?

The question now is, why the report shows them as not covered. Can you please drill down the report to a single class? There might be a hint ;)

Cheers,
-marc


On 7. Jul 2020, at 16:03, geob...@gmail.com wrote:



<cmd_out.PNG><cmd_out_1.PNG><rep.PNG><session.PNG>

To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/6fd11f89-afc6-4a10-b7a9-e88274b46555o%40googlegroups.com.
<cmd_out.PNG><cmd_out_1.PNG><rep.PNG><session.PNG>

geob...@gmail.com

unread,
Jul 7, 2020, 11:02:53 AM7/7/20
to JaCoCo and EclEmma Users
I am sorry, but what do you mean by drill down the report to a single class? I have copied the classfiles from my application and stored them in a separate folder. I then have pointed classfile argument for the report generation command to this folder to iterate through the classes and determine the code coverage. Is this not best practice?

Marc Hoffmann

unread,
Jul 7, 2020, 11:04:48 AM7/7/20
to JaCoCo and EclEmma Users
Sorry, I mean navigating the links in the HTML report:

Click on the package link, click on a class in the package (that you would expect to be executed).


To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/940dcc96-b6df-4dad-82fa-12d237a0f3f6o%40googlegroups.com.

geob...@gmail.com

unread,
Jul 7, 2020, 11:12:58 AM7/7/20
to JaCoCo and EclEmma Users
Regardless of the class I go to it says the source file not found. To generate the report, are the source files necessary?

geob...@gmail.com

unread,
Jul 7, 2020, 11:43:39 AM7/7/20
to JaCoCo and EclEmma Users
The reason I ask if the source files are necessary, is because I have been able to generate code coverage reports with non-zero results without the source files before.

Marc Hoffmann

unread,
Jul 7, 2020, 11:57:45 AM7/7/20
to JaCoCo and EclEmma Users
Ok, that is not the reason. I was looking for a different hint.

If you go to the Sessions page of the HTML report:

* Can you see your application classes?
* Are the classes linked to the report (or plain text)?




To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/97501194-19ce-4e84-80e8-f191f1fd03abo%40googlegroups.com.

Message has been deleted

geob...@gmail.com

unread,
Jul 7, 2020, 12:30:52 PM7/7/20
to JaCoCo and EclEmma Users
If I navigate to the session page, all the classes are written in plain text and they are not the classes my report command points to with the classfile argument. I have attached a screenshot of the sessions page. Why would this be the case?

Capture.PNG

Marc Hoffmann

unread,
Jul 7, 2020, 1:56:19 PM7/7/20
to JaCoCo and EclEmma Users
Just to be sure: Beside org.apache.* classes you you also see the classes of your application in the list? 


On 7. Jul 2020, at 18:30, geob...@gmail.com wrote:

If I navigate to the session page, all the classes are written in plain text and they are not the classes my report command points to with the classfile argument. I have attached a screenshot of the sessions page. Why would this be the case?

<Capture.PNG>

To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/07b36faa-f2c0-468e-bdc2-a458884800c5o%40googlegroups.com.
<Capture.PNG>

geob...@gmail.com

unread,
Jul 7, 2020, 2:09:01 PM7/7/20
to JaCoCo and EclEmma Users
No, none of the classes classes that I have copied and set aside for report generation appear on the sessions page.
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/07b36faa-f2c0-468e-bdc2-a458884800c5o%40googlegroups.com.
<Capture.PNG>

Marc Hoffmann

unread,
Jul 7, 2020, 3:28:43 PM7/7/20
to JaCoCo and EclEmma Users
This means they have not been loaded by the JVM where you attached the JaCoCo agent.


To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/14618c5e-6f82-4a81-bb05-df9640bbdf0fo%40googlegroups.com.

geob...@gmail.com

unread,
Jul 7, 2020, 3:38:46 PM7/7/20
to JaCoCo and EclEmma Users
How can this be fixed? I am sorry for the onslaught of questions.
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/14618c5e-6f82-4a81-bb05-df9640bbdf0fo%40googlegroups.com.

Marc Hoffmann

unread,
Jul 8, 2020, 2:02:39 AM7/8/20
to jac...@googlegroups.com
Well, you need to understand how your classes under tests are actually executed, in particular what JVM instance is used for it and configure this JVM.

As a side note: Did you actually execute the functionality of your classes when creating the test reports? In Eclipse RCP classes are loaded lazy. So you can for example see menu items or toolbar buttons without any classes loaded. Only if you actually trigger a specific functionality (e.g. open a dialog, open a view) the respective classes are loaded.

To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/bc38b6df-32cb-422c-ad2e-00e1af8e7969o%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages