You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2015/04/19 09:13:12 UTC

[WANNA HELP WITH] - Camel route coverage report for running unit tests

Hi

We are working on a new functionality to generate Camel route coverage
reports from running unit tests.

The ticket is: https://issues.apache.org/jira/browse/CAMEL-8657

What currently happens is that camel-test modules can run in a
coverage mode, and then after each test write a coverage data as xml
files to target/camel-route-coverage directory.

I posted a tweet with screenshot about this
https://twitter.com/davsclaus/status/589357264345108480

What is left to do is some notes I have written to the CAMEL-8657 ticket.

But basically what is needed is a new maven plugin that generates the
report in a nice html format, so people can easily view the coverage.

I attached a screenshot of cobertura report, I wonder if the html
report should be something similar?

The dump is the routes in xml with coverage data enriched. So what is
needed is to render this as html, and then draw green / red lines etc
if the exchangeTotal is 0 or > 0 etc.

We can enrich more data in the dump if we want to. I just started with
the total number of exchanges and their processing time.

We have some existing maven plugins at
https://github.com/apache/camel/tree/master/tooling/maven

But I guess this new one is about a maven report and needs to run in
after test scope or something.

The code coverage stats is retrieved using the api on camel context mbean
https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java#L190

Which camel-test uses
https://github.com/apache/camel/blob/master/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java#L365

We need a smart way of enabling this in camel-test, for example it
would be nice if just by adding the report maven plugin to the pom.xml
would do this. Or some easy option to turn it on. As it requires JMX
then its not on by default as camel-test runs with JMX disabled by
default (this runs tests a little bit faster).

Though we could consider enabling JMX by default for testing? They
were disabled as running the entire Camel test suite was 5-10% faster
by doing so.

In camel-test the filter unit test is enabled the route coverage, so
if you run mvn clean install in camel-test module then you get a
report files.





-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: [WANNA HELP WITH] - Camel route coverage report for running unit tests

Posted by Greg Autric <ga...@redhat.com>.
Hi Claus,

We can create an XSLT to convert XML to HTML.
I think it is the quickest way to achieve it.
could you post an XML Camel code coverage sample ? 

Greg I/O


Le dimanche 19 avril 2015 à 09:13 +0200, Claus Ibsen a écrit :
> Hi
> 
> We are working on a new functionality to generate Camel route coverage
> reports from running unit tests.
> 
> The ticket is: https://issues.apache.org/jira/browse/CAMEL-8657
> 
> What currently happens is that camel-test modules can run in a
> coverage mode, and then after each test write a coverage data as xml
> files to target/camel-route-coverage directory.
> 
> I posted a tweet with screenshot about this
> https://twitter.com/davsclaus/status/589357264345108480
> 
> What is left to do is some notes I have written to the CAMEL-8657 ticket.
> 
> But basically what is needed is a new maven plugin that generates the
> report in a nice html format, so people can easily view the coverage.
> 
> I attached a screenshot of cobertura report, I wonder if the html
> report should be something similar?
> 
> The dump is the routes in xml with coverage data enriched. So what is
> needed is to render this as html, and then draw green / red lines etc
> if the exchangeTotal is 0 or > 0 etc.
> 
> We can enrich more data in the dump if we want to. I just started with
> the total number of exchanges and their processing time.
> 
> We have some existing maven plugins at
> https://github.com/apache/camel/tree/master/tooling/maven
> 
> But I guess this new one is about a maven report and needs to run in
> after test scope or something.
> 
> The code coverage stats is retrieved using the api on camel context mbean
> https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java#L190
> 
> Which camel-test uses
> https://github.com/apache/camel/blob/master/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java#L365
> 
> We need a smart way of enabling this in camel-test, for example it
> would be nice if just by adding the report maven plugin to the pom.xml
> would do this. Or some easy option to turn it on. As it requires JMX
> then its not on by default as camel-test runs with JMX disabled by
> default (this runs tests a little bit faster).
> 
> Though we could consider enabling JMX by default for testing? They
> were disabled as running the entire Camel test suite was 5-10% faster
> by doing so.
> 
> In camel-test the filter unit test is enabled the route coverage, so
> if you run mvn clean install in camel-test module then you get a
> report files.
> 
> 
> 
> 
>