I have a web application built using Java/IntelliJ. But all my tests are written in C#/VisualStudio. In my test, I construct the http request and send to the java application. I parse the response to make sure the application is working correctly. Is there a way to use the IntelliJ plugin for clover coverage tool to measure the code coverage?
The code coverage does not have to be per-test basis. If I can start the java app in my local intelliJ and manually start my test in visual studio (also locally) and get a coverage report for whole test run, that is sufficient.
Yes you can do this.
Clover measures code coverage of a running application no matter how it was launched. It can be a unit, manual test or an external test, like in your C#.
Just compile your project with Clover and launch the application.
In case you launch it from a different working directory than a workspace, then you may need to add -Dclover.inistring=/path/to/clover.db (by default it's in <workspace>/.clover/clover.db) JVM arg in your run configuration. Alternatively you can use an absolute path to a database (Settings > Other settings > Clover (project settings) > Instrumentation > Initstring).
Coverage recording files will be written to disk at application shutdown. Thus you have to stop your app to see coverage in IDEA. Alternatively, you can switch the flush policy to "interval" or "threaded" (Settings > Other settings > Clover (project settings) > Instrumentation > Flush policy) to have coverage data written on the fly, without shutting down the app.
Thanks Marek for getting back to me. I've tried everything as you described, but it doesn't seem to be making any recording. We have few Java unit tests, and when I run those tests directly from my IntelliJ, I do get the coverage report directly in the IDE showing me the covered lines. But this is not the case for the C# tests. Here's what I'm doing. After doing the default install, I get the little tool bar with the clover control. On it, I have the following enabled: Toggle Build with Clover, Annotate icons of files..., Toggle view coverage, Turn on coverage highlight Then I rebuild the project. Then I "Run 'MyApp' with Coverage". Once I have the app running, I got to my visual studio and run my tests. After running the test, I go back to my IntelliJ and stop the app. I get Coverage report in my IntelliJ IDE but everything is at 0% coverage. Even the lines of code that I expect to be covered shows as not covered. I did verify that my working directory and workspace is the same. I also tried setting the JVM argument as well as trying to set the absolute path to database, non of which seems to make any difference. And since the unit tests are reporting correctly, I expect that the path to database is not the problem. Any additional help would be very much appreciated. :)
Hi Steven, please check the following: 1) Does Clover create a database after compilation (should be in .clover/clover.db or sth)? 2) Does this database contain your application classes? You can check it in the 'Cloverage' view, whether it lists all classes. Or by generating an HTML report. 3) When running your C# tests - do you see coverage recording files (named like 'clover.dbsomehashcode') in the folder where clover.db is located? * did you use interval or threaded flush policy? * did you try to shut down the application? 4) If coverage recording files are not present, then there's something wrong upon application startup. For instance: * Clover's coverage recorders may failed to find the clover.db - please check your application logs for any Clover-related messages * you may be using a default (directed) flush policy and killing JVM instead of exiting it normally; in such case JVM's shutdown hook, to which Clover is attached to, may not be called * you can also add -Dclover.logging.level=debug to JVM arg to see what Clover does at runtime * you have launched a non-instrumented application - did you rebuild entire project with Clover? what kind of run configuration do you use in IDEA to launch an app? is it a standard 'Application' one? or maybe you call some custom startup scripts? 5) If coverage recording files are present, then Clover IDEA plugin did not refresh its views. Try clicking the "Refresh" button in the Cloverage view in such case.
You wrote that:
Then I "Run 'MyApp' with Coverage".
Do you mean that you clicked the following button?:
If yes, then you've just used IDEA's built-in coverage tool, not Clover.
Please try to run your application using the standard 'Run' button.
Thanks Marek. It turns out that my problem was that the logs were not being written to the clover.db as the application was exiting. I changed the default Flush Policy from Directed to Interval and I was able to see the result. The funny thing is that I am pressing the standard stop (red square) button to exit the application. At least for now, I can do a bit of evaluation, then move on to solving the next problem :) Thanks for all your help. ps. it turns out that I can use any run of the run button to measure the coverage, although as you have suggested, I should be using the standard run button.
Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs