Quantcast

Sonar reuseReports doesn't work for emma and cobertura

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Sonar reuseReports doesn't work for emma and cobertura

Bartłomiej Budz
Hi

I will try to describe my problem briefly.
I'm trying to deliver code coverage report to sonar. I have reports in
emma (ec and em files) and in cobertura xml file.
In both cases everything works well (project is added to sonar,
surefire reports are shown etc) but there is "-" coverage score.
In command prompt I should see 'EmmaSensor' or 'CoberturaSensor' or
sth, should I? There isn't anything indicating that emma or cobertura
plugin is used.
I tested in both with Ant and Maven, for emma and cobertura.
I tested also for jacoco, giving fake report path and it shows
JacocoSensor message that coverage is 0% (in command prompt)

I tested with sonar 2.14, 3.1.1, emma plugin 1.0.1 and 1.2.1; windows 7 x64

Maybe you can point me what I'm doing wrong?
Do somebody use reuseReports with emma or cobertura?

Below you can see my build.xml and pom.xml files for emma. As for
cobertura, it's similar, only path is cobertura/coverage.xml.

------------------------
build.xml (ANT)
------------------------
<?xml version="1.0"?>
<project name = "Code Coverage - ant" default = "sonar" basedir = ".">
        <target name="sonar">
                <property name="sonar.jdbc.url" value="jdbc:mysql://localhost:3306/sonar" />
              <property name="sonar.jdbc.driver" value="com.mysql.jdbc.Driver" />
              <property name="sonar.jdbc.username" value="root" />
              <property name="sonar.jdbc.password" value="" />

                <property name="sonar.sources" value="src" />
                <property name="sonar.tests" value="tests" />

                <property name="sonar.dynamicAnalysis" value="reuseReports" />
                <property name="sonar.codeCoveragePlugin" value="emma" />
                <property name="sonar.surefire.reportsPath" value="reports" />
                <property name="sonar.emma.reportPath" value="CodeCoverage" />

                <property name="sonar.importSources" value="false" />
                <sonar:sonar key="cc.test" version="0.1" xmlns:sonar="antlib:org.sonar.ant" />
        </target>
</project>
------------------------
pom.xml (MAVEN)
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.codehaus.sonar</groupId>
  <artifactId>example-ut-maven-emma-runTests</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>Code Coverage - maven</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <sonar.language>java</sonar.language>
        <sonar.sources>src</sonar.sources>
        <sonar.tests>tests</sonar.tests>
       
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
    <sonar.surefire.reportsPath>reports</sonar.surefire.reportsPath>
    <sonar.emma.reportPath>CodeCoverage</sonar.emma.reportPath>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
       </plugin>
    </plugins>
  </build>

</project>

Thanks,
Bart

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sonar reuseReports doesn't work for emma and cobertura

David Racodon-2
Hi Bart,

As mentioned in the documentation, you must set the path to the report file (not the path to the directory containing the report file). See  http://docs.codehaus.org/display/SONAR/Analysis+Parameters#AnalysisParameters-UnitandIntegrationTests.

Note that there are also plenty of examples for code coverage here: https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut.

Regards,

David RACODON | SonarSource
Senior Consultant



On 10 August 2012 16:07, Bartłomiej Budz <[hidden email]> wrote:
Hi

I will try to describe my problem briefly.
I'm trying to deliver code coverage report to sonar. I have reports in
emma (ec and em files) and in cobertura xml file.
In both cases everything works well (project is added to sonar,
surefire reports are shown etc) but there is "-" coverage score.
In command prompt I should see 'EmmaSensor' or 'CoberturaSensor' or
sth, should I? There isn't anything indicating that emma or cobertura
plugin is used.
I tested in both with Ant and Maven, for emma and cobertura.
I tested also for jacoco, giving fake report path and it shows
JacocoSensor message that coverage is 0% (in command prompt)

I tested with sonar 2.14, 3.1.1, emma plugin 1.0.1 and 1.2.1; windows 7 x64

Maybe you can point me what I'm doing wrong?
Do somebody use reuseReports with emma or cobertura?

Below you can see my build.xml and pom.xml files for emma. As for
cobertura, it's similar, only path is cobertura/coverage.xml.

------------------------
build.xml (ANT)
------------------------
<?xml version="1.0"?>
<project name = "Code Coverage - ant" default = "sonar" basedir = ".">
        <target name="sonar">
                <property name="sonar.jdbc.url" value="jdbc:mysql://localhost:3306/sonar" />
                <property name="sonar.jdbc.driver" value="com.mysql.jdbc.Driver" />
                <property name="sonar.jdbc.username" value="root" />
                <property name="sonar.jdbc.password" value="" />

                <property name="sonar.sources" value="src" />
                <property name="sonar.tests" value="tests" />

                <property name="sonar.dynamicAnalysis" value="reuseReports" />
                <property name="sonar.codeCoveragePlugin" value="emma" />
                <property name="sonar.surefire.reportsPath" value="reports" />
                <property name="sonar.emma.reportPath" value="CodeCoverage" />

                <property name="sonar.importSources" value="false" />
                <sonar:sonar key="cc.test" version="0.1" xmlns:sonar="antlib:org.sonar.ant" />
        </target>
</project>
------------------------
pom.xml (MAVEN)
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.codehaus.sonar</groupId>
  <artifactId>example-ut-maven-emma-runTests</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>Code Coverage - maven</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <sonar.language>java</sonar.language>
        <sonar.sources>src</sonar.sources>
        <sonar.tests>tests</sonar.tests>

    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
    <sonar.surefire.reportsPath>reports</sonar.surefire.reportsPath>
    <sonar.emma.reportPath>CodeCoverage</sonar.emma.reportPath>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
       </plugin>
    </plugins>
  </build>

</project>

Thanks,
Bart

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sonar reuseReports doesn't work for emma and cobertura

Bartłomiej Budz
Hi

Firts, thanks for your reply.
If i have to set path for file, why on this page:
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
i found sentence: "Tell Sonar where your code coverage report is:
absolute or relative path to the report file for JaCoCo or Cobertura
or Clover, DIRECTORY path for Emma." (last section:  "Code Coverage
Report")?
I tried to run examples. But I found that there (probably) are some
errors, for example:
https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-emma-reuseReports/pom.xml
it's most suitable example to my problem, but in file name there is
"reuseReports", yet in 14h line there is:
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
As I think, there is big difference between reuseReports and dynamicAnalysis.
If I understood it well, i have to reuse report, if i generate it
earlier then I run sonar analysis.
Am I right?

Regards
Bart


2012/8/10 David Racodon <[hidden email]>:

> Hi Bart,
>
> As mentioned in the documentation, you must set the path to the report file
> (not the path to the directory containing the report file). See
> http://docs.codehaus.org/display/SONAR/Analysis+Parameters#AnalysisParameters-UnitandIntegrationTests.
>
> Note that there are also plenty of examples for code coverage here:
> https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut.
>
> Regards,
>
> David RACODON | SonarSource
> Senior Consultant
> http://sonarsource.com
>
>
>
> On 10 August 2012 16:07, Bartłomiej Budz <[hidden email]> wrote:
>>
>> Hi
>>
>> I will try to describe my problem briefly.
>> I'm trying to deliver code coverage report to sonar. I have reports in
>> emma (ec and em files) and in cobertura xml file.
>> In both cases everything works well (project is added to sonar,
>> surefire reports are shown etc) but there is "-" coverage score.
>> In command prompt I should see 'EmmaSensor' or 'CoberturaSensor' or
>> sth, should I? There isn't anything indicating that emma or cobertura
>> plugin is used.
>> I tested in both with Ant and Maven, for emma and cobertura.
>> I tested also for jacoco, giving fake report path and it shows
>> JacocoSensor message that coverage is 0% (in command prompt)
>>
>> I tested with sonar 2.14, 3.1.1, emma plugin 1.0.1 and 1.2.1; windows 7
>> x64
>>
>> Maybe you can point me what I'm doing wrong?
>> Do somebody use reuseReports with emma or cobertura?
>>
>> Below you can see my build.xml and pom.xml files for emma. As for
>> cobertura, it's similar, only path is cobertura/coverage.xml.
>>
>> ------------------------
>> build.xml (ANT)
>> ------------------------
>> <?xml version="1.0"?>
>> <project name = "Code Coverage - ant" default = "sonar" basedir = ".">
>>         <target name="sonar">
>>                 <property name="sonar.jdbc.url"
>> value="jdbc:mysql://localhost:3306/sonar" />
>>                 <property name="sonar.jdbc.driver"
>> value="com.mysql.jdbc.Driver" />
>>                 <property name="sonar.jdbc.username" value="root" />
>>                 <property name="sonar.jdbc.password" value="" />
>>
>>                 <property name="sonar.sources" value="src" />
>>                 <property name="sonar.tests" value="tests" />
>>
>>                 <property name="sonar.dynamicAnalysis"
>> value="reuseReports" />
>>                 <property name="sonar.codeCoveragePlugin" value="emma" />
>>                 <property name="sonar.surefire.reportsPath"
>> value="reports" />
>>                 <property name="sonar.emma.reportPath"
>> value="CodeCoverage" />
>>
>>                 <property name="sonar.importSources" value="false" />
>>                 <sonar:sonar key="cc.test" version="0.1"
>> xmlns:sonar="antlib:org.sonar.ant" />
>>         </target>
>> </project>
>> ------------------------
>> pom.xml (MAVEN)
>> ------------------------
>> <?xml version="1.0" encoding="UTF-8"?>
>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>>   <modelVersion>4.0.0</modelVersion>
>>   <groupId>org.codehaus.sonar</groupId>
>>   <artifactId>example-ut-maven-emma-runTests</artifactId>
>>   <version>1.0-SNAPSHOT</version>
>>
>>   <name>Code Coverage - maven</name>
>>
>>   <properties>
>>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>         <sonar.language>java</sonar.language>
>>         <sonar.sources>src</sonar.sources>
>>         <sonar.tests>tests</sonar.tests>
>>
>>     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
>>     <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
>>     <sonar.surefire.reportsPath>reports</sonar.surefire.reportsPath>
>>     <sonar.emma.reportPath>CodeCoverage</sonar.emma.reportPath>
>>   </properties>
>>
>>   <dependencies>
>>     <dependency>
>>       <groupId>junit</groupId>
>>       <artifactId>junit</artifactId>
>>       <version>4.8.1</version>
>>       <scope>test</scope>
>>     </dependency>
>>   </dependencies>
>>
>>   <build>
>>     <plugins>
>>       <plugin>
>>         <groupId>org.apache.maven.plugins</groupId>
>>         <artifactId>maven-compiler-plugin</artifactId>
>>         <configuration>
>>           <source>1.5</source>
>>           <target>1.5</target>
>>         </configuration>
>>        </plugin>
>>     </plugins>
>>   </build>
>>
>> </project>
>>
>> Thanks,
>> Bart
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Bartek
---------------------
GG: 4323480
Skype: bartekblues
www.bialka.net

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sonar reuseReports doesn't work for emma and cobertura

David Racodon-2
Hi Bart,

If i have to set path for file, why on this page:
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
i found sentence: "Tell Sonar where your code coverage report is:
absolute or relative path to the report file for JaCoCo or Cobertura
or Clover, DIRECTORY path for Emma." (last section:  "Code Coverage
Report")? 

My mistake. You're right, directory path indeed for Emma as there are multiple files.


I tried to run examples. But I found that there (probably) are some
errors, for example:
https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-emma-reuseReports/pom.xml
it's most suitable example to my problem, but in file name there is
"reuseReports", yet in 14h line there is:
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>

There was a typo in the directory name. I renamed it in ut-maven-emma-runTests.
 

As I think, there is big difference between reuseReports and dynamicAnalysis.
If I understood it well, i have to reuse report, if i generate it
earlier then I run sonar analysis.

100% correct.


Have you added the Sonar Emma plugin on your Sonar platform?

I added a sample project: ut-maven-emma-reuseReports.
Could you please try again both projects?:
  • ut-maven-emma-runTests
  • ut-maven-emma-reuseReports

Thank you

Regards, 


David RACODON | SonarSource
Senior Consultant



On 10 August 2012 16:51, Bartłomiej Budz <[hidden email]> wrote:
Hi

Firts, thanks for your reply.
If i have to set path for file, why on this page:
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
i found sentence: "Tell Sonar where your code coverage report is:
absolute or relative path to the report file for JaCoCo or Cobertura
or Clover, DIRECTORY path for Emma." (last section:  "Code Coverage
Report")?
I tried to run examples. But I found that there (probably) are some
errors, for example:
https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-emma-reuseReports/pom.xml
it's most suitable example to my problem, but in file name there is
"reuseReports", yet in 14h line there is:
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
As I think, there is big difference between reuseReports and dynamicAnalysis.
If I understood it well, i have to reuse report, if i generate it
earlier then I run sonar analysis.
Am I right?

Regards
Bart


2012/8/10 David Racodon <[hidden email]>:
> Hi Bart,
>
> As mentioned in the documentation, you must set the path to the report file
> (not the path to the directory containing the report file). See
> http://docs.codehaus.org/display/SONAR/Analysis+Parameters#AnalysisParameters-UnitandIntegrationTests.
>
> Note that there are also plenty of examples for code coverage here:
> https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut.
>
> Regards,
>
> David RACODON | SonarSource
> Senior Consultant
> http://sonarsource.com
>
>
>
> On 10 August 2012 16:07, Bartłomiej Budz <[hidden email]> wrote:
>>
>> Hi
>>
>> I will try to describe my problem briefly.
>> I'm trying to deliver code coverage report to sonar. I have reports in
>> emma (ec and em files) and in cobertura xml file.
>> In both cases everything works well (project is added to sonar,
>> surefire reports are shown etc) but there is "-" coverage score.
>> In command prompt I should see 'EmmaSensor' or 'CoberturaSensor' or
>> sth, should I? There isn't anything indicating that emma or cobertura
>> plugin is used.
>> I tested in both with Ant and Maven, for emma and cobertura.
>> I tested also for jacoco, giving fake report path and it shows
>> JacocoSensor message that coverage is 0% (in command prompt)
>>
>> I tested with sonar 2.14, 3.1.1, emma plugin 1.0.1 and 1.2.1; windows 7
>> x64
>>
>> Maybe you can point me what I'm doing wrong?
>> Do somebody use reuseReports with emma or cobertura?
>>
>> Below you can see my build.xml and pom.xml files for emma. As for
>> cobertura, it's similar, only path is cobertura/coverage.xml.
>>
>> ------------------------
>> build.xml (ANT)
>> ------------------------
>> <?xml version="1.0"?>
>> <project name = "Code Coverage - ant" default = "sonar" basedir = ".">
>>         <target name="sonar">
>>                 <property name="sonar.jdbc.url"
>> value="jdbc:mysql://localhost:3306/sonar" />
>>                 <property name="sonar.jdbc.driver"
>> value="com.mysql.jdbc.Driver" />
>>                 <property name="sonar.jdbc.username" value="root" />
>>                 <property name="sonar.jdbc.password" value="" />
>>
>>                 <property name="sonar.sources" value="src" />
>>                 <property name="sonar.tests" value="tests" />
>>
>>                 <property name="sonar.dynamicAnalysis"
>> value="reuseReports" />
>>                 <property name="sonar.codeCoveragePlugin" value="emma" />
>>                 <property name="sonar.surefire.reportsPath"
>> value="reports" />
>>                 <property name="sonar.emma.reportPath"
>> value="CodeCoverage" />
>>
>>                 <property name="sonar.importSources" value="false" />
>>                 <sonar:sonar key="cc.test" version="0.1"
>> xmlns:sonar="antlib:org.sonar.ant" />
>>         </target>
>> </project>
>> ------------------------
>> pom.xml (MAVEN)
>> ------------------------
>> <?xml version="1.0" encoding="UTF-8"?>
>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>>   <modelVersion>4.0.0</modelVersion>
>>   <groupId>org.codehaus.sonar</groupId>
>>   <artifactId>example-ut-maven-emma-runTests</artifactId>
>>   <version>1.0-SNAPSHOT</version>
>>
>>   <name>Code Coverage - maven</name>
>>
>>   <properties>
>>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>         <sonar.language>java</sonar.language>
>>         <sonar.sources>src</sonar.sources>
>>         <sonar.tests>tests</sonar.tests>
>>
>>     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
>>     <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
>>     <sonar.surefire.reportsPath>reports</sonar.surefire.reportsPath>
>>     <sonar.emma.reportPath>CodeCoverage</sonar.emma.reportPath>
>>   </properties>
>>
>>   <dependencies>
>>     <dependency>
>>       <groupId>junit</groupId>
>>       <artifactId>junit</artifactId>
>>       <version>4.8.1</version>
>>       <scope>test</scope>
>>     </dependency>
>>   </dependencies>
>>
>>   <build>
>>     <plugins>
>>       <plugin>
>>         <groupId>org.apache.maven.plugins</groupId>
>>         <artifactId>maven-compiler-plugin</artifactId>
>>         <configuration>
>>           <source>1.5</source>
>>           <target>1.5</target>
>>         </configuration>
>>        </plugin>
>>     </plugins>
>>   </build>
>>
>> </project>
>>
>> Thanks,
>> Bart
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Bartek
---------------------
GG: 4323480
Skype: bartekblues
www.bialka.net

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sonar reuseReports doesn't work for emma and cobertura

Bartłomiej Budz
Hi
Probably I found solution of the problem. I think it should be
mentioned in the documentation.
I had empty directory of source code. It worked well with unit tests
reports ("sonar.surefire.reportsPath") but in case of re-using
coverage reports, it's necessary to have source code, I think.
It might seem obvious - if somebody are suing sonar, should have
sources - but I used it only to test coverage plugin, and I didn't
even imagine that it's required.
Please, let me know if I'm right or wrong.

Regards
Bart

Ps. Yes, I have emma plugin on my sonar platform.

2012/8/13 David Racodon <[hidden email]>:

> Hi Bart,
>
>> If i have to set path for file, why on this page:
>> http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
>> i found sentence: "Tell Sonar where your code coverage report is:
>> absolute or relative path to the report file for JaCoCo or Cobertura
>> or Clover, DIRECTORY path for Emma." (last section:  "Code Coverage
>> Report")?
>
>
> My mistake. You're right, directory path indeed for Emma as there are
> multiple files.
>
>
>> I tried to run examples. But I found that there (probably) are some
>> errors, for example:
>>
>> https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-emma-reuseReports/pom.xml
>> it's most suitable example to my problem, but in file name there is
>> "reuseReports", yet in 14h line there is:
>> <sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
>
>
> There was a typo in the directory name. I renamed it in
> ut-maven-emma-runTests.
>
>
>> As I think, there is big difference between reuseReports and
>> dynamicAnalysis.
>> If I understood it well, i have to reuse report, if i generate it
>> earlier then I run sonar analysis.
>
>
> 100% correct.
>
>
> Have you added the Sonar Emma plugin on your Sonar platform?
>
> I added a sample project: ut-maven-emma-reuseReports.
> Could you please try again both projects?:
>
> ut-maven-emma-runTests
> ut-maven-emma-reuseReports
>
>
> Thank you
>
> Regards,
>
>
> David RACODON | SonarSource
> Senior Consultant
> http://sonarsource.com
>
>
>
> On 10 August 2012 16:51, Bartłomiej Budz <[hidden email]> wrote:
>>
>> Hi
>>
>> Firts, thanks for your reply.
>> If i have to set path for file, why on this page:
>> http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
>> i found sentence: "Tell Sonar where your code coverage report is:
>> absolute or relative path to the report file for JaCoCo or Cobertura
>> or Clover, DIRECTORY path for Emma." (last section:  "Code Coverage
>> Report")?
>> I tried to run examples. But I found that there (probably) are some
>> errors, for example:
>>
>> https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-emma-reuseReports/pom.xml
>> it's most suitable example to my problem, but in file name there is
>> "reuseReports", yet in 14h line there is:
>> <sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
>> As I think, there is big difference between reuseReports and
>> dynamicAnalysis.
>> If I understood it well, i have to reuse report, if i generate it
>> earlier then I run sonar analysis.
>> Am I right?
>>
>> Regards
>> Bart
>>
>>
>> 2012/8/10 David Racodon <[hidden email]>:
>> > Hi Bart,
>> >
>> > As mentioned in the documentation, you must set the path to the report
>> > file
>> > (not the path to the directory containing the report file). See
>> >
>> > http://docs.codehaus.org/display/SONAR/Analysis+Parameters#AnalysisParameters-UnitandIntegrationTests.
>> >
>> > Note that there are also plenty of examples for code coverage here:
>> >
>> > https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut.
>> >
>> > Regards,
>> >
>> > David RACODON | SonarSource
>> > Senior Consultant
>> > http://sonarsource.com
>> >
>> >
>> >
>> > On 10 August 2012 16:07, Bartłomiej Budz <[hidden email]> wrote:
>> >>
>> >> Hi
>> >>
>> >> I will try to describe my problem briefly.
>> >> I'm trying to deliver code coverage report to sonar. I have reports in
>> >> emma (ec and em files) and in cobertura xml file.
>> >> In both cases everything works well (project is added to sonar,
>> >> surefire reports are shown etc) but there is "-" coverage score.
>> >> In command prompt I should see 'EmmaSensor' or 'CoberturaSensor' or
>> >> sth, should I? There isn't anything indicating that emma or cobertura
>> >> plugin is used.
>> >> I tested in both with Ant and Maven, for emma and cobertura.
>> >> I tested also for jacoco, giving fake report path and it shows
>> >> JacocoSensor message that coverage is 0% (in command prompt)
>> >>
>> >> I tested with sonar 2.14, 3.1.1, emma plugin 1.0.1 and 1.2.1; windows 7
>> >> x64
>> >>
>> >> Maybe you can point me what I'm doing wrong?
>> >> Do somebody use reuseReports with emma or cobertura?
>> >>
>> >> Below you can see my build.xml and pom.xml files for emma. As for
>> >> cobertura, it's similar, only path is cobertura/coverage.xml.
>> >>
>> >> ------------------------
>> >> build.xml (ANT)
>> >> ------------------------
>> >> <?xml version="1.0"?>
>> >> <project name = "Code Coverage - ant" default = "sonar" basedir = ".">
>> >>         <target name="sonar">
>> >>                 <property name="sonar.jdbc.url"
>> >> value="jdbc:mysql://localhost:3306/sonar" />
>> >>                 <property name="sonar.jdbc.driver"
>> >> value="com.mysql.jdbc.Driver" />
>> >>                 <property name="sonar.jdbc.username" value="root" />
>> >>                 <property name="sonar.jdbc.password" value="" />
>> >>
>> >>                 <property name="sonar.sources" value="src" />
>> >>                 <property name="sonar.tests" value="tests" />
>> >>
>> >>                 <property name="sonar.dynamicAnalysis"
>> >> value="reuseReports" />
>> >>                 <property name="sonar.codeCoveragePlugin" value="emma"
>> >> />
>> >>                 <property name="sonar.surefire.reportsPath"
>> >> value="reports" />
>> >>                 <property name="sonar.emma.reportPath"
>> >> value="CodeCoverage" />
>> >>
>> >>                 <property name="sonar.importSources" value="false" />
>> >>                 <sonar:sonar key="cc.test" version="0.1"
>> >> xmlns:sonar="antlib:org.sonar.ant" />
>> >>         </target>
>> >> </project>
>> >> ------------------------
>> >> pom.xml (MAVEN)
>> >> ------------------------
>> >> <?xml version="1.0" encoding="UTF-8"?>
>> >> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> >> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> >> http://maven.apache.org/maven-v4_0_0.xsd">
>> >>   <modelVersion>4.0.0</modelVersion>
>> >>   <groupId>org.codehaus.sonar</groupId>
>> >>   <artifactId>example-ut-maven-emma-runTests</artifactId>
>> >>   <version>1.0-SNAPSHOT</version>
>> >>
>> >>   <name>Code Coverage - maven</name>
>> >>
>> >>   <properties>
>> >>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> >>         <sonar.language>java</sonar.language>
>> >>         <sonar.sources>src</sonar.sources>
>> >>         <sonar.tests>tests</sonar.tests>
>> >>
>> >>     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
>> >>     <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
>> >>     <sonar.surefire.reportsPath>reports</sonar.surefire.reportsPath>
>> >>     <sonar.emma.reportPath>CodeCoverage</sonar.emma.reportPath>
>> >>   </properties>
>> >>
>> >>   <dependencies>
>> >>     <dependency>
>> >>       <groupId>junit</groupId>
>> >>       <artifactId>junit</artifactId>
>> >>       <version>4.8.1</version>
>> >>       <scope>test</scope>
>> >>     </dependency>
>> >>   </dependencies>
>> >>
>> >>   <build>
>> >>     <plugins>
>> >>       <plugin>
>> >>         <groupId>org.apache.maven.plugins</groupId>
>> >>         <artifactId>maven-compiler-plugin</artifactId>
>> >>         <configuration>
>> >>           <source>1.5</source>
>> >>           <target>1.5</target>
>> >>         </configuration>
>> >>        </plugin>
>> >>     </plugins>
>> >>   </build>
>> >>
>> >> </project>
>> >>
>> >> Thanks,
>> >> Bart
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>     http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Bartek
>> ---------------------
>> GG: 4323480
>> Skype: bartekblues
>> www.bialka.net
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Bartek
---------------------
GG: 4323480
Skype: bartekblues
www.bialka.net

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sonar reuseReports doesn't work for emma and cobertura

David Racodon-2
Hi Bart,

Yes, obviously, it's necessary to have source code to run a Sonar analysis... otherwise I don't really see any interest in using Sonar.
For your information, in case of an empty source file folder, for Sonar 3.2+, the analysis explicitly fails with the following message: Project "myProject" does not contain any file in its source folders.

Regards,

David RACODON | SonarSource
Senior Consultant



On 13 August 2012 12:55, Bartłomiej Budz <[hidden email]> wrote:
Hi
Probably I found solution of the problem. I think it should be
mentioned in the documentation.
I had empty directory of source code. It worked well with unit tests
reports ("sonar.surefire.reportsPath") but in case of re-using
coverage reports, it's necessary to have source code, I think.
It might seem obvious - if somebody are suing sonar, should have
sources - but I used it only to test coverage plugin, and I didn't
even imagine that it's required.
Please, let me know if I'm right or wrong.

Regards
Bart

Ps. Yes, I have emma plugin on my sonar platform.

2012/8/13 David Racodon <[hidden email]>:
> Hi Bart,
>
>> If i have to set path for file, why on this page:
>> http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
>> i found sentence: "Tell Sonar where your code coverage report is:
>> absolute or relative path to the report file for JaCoCo or Cobertura
>> or Clover, DIRECTORY path for Emma." (last section:  "Code Coverage
>> Report")?
>
>
> My mistake. You're right, directory path indeed for Emma as there are
> multiple files.
>
>
>> I tried to run examples. But I found that there (probably) are some
>> errors, for example:
>>
>> https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-emma-reuseReports/pom.xml
>> it's most suitable example to my problem, but in file name there is
>> "reuseReports", yet in 14h line there is:
>> <sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
>
>
> There was a typo in the directory name. I renamed it in
> ut-maven-emma-runTests.
>
>
>> As I think, there is big difference between reuseReports and
>> dynamicAnalysis.
>> If I understood it well, i have to reuse report, if i generate it
>> earlier then I run sonar analysis.
>
>
> 100% correct.
>
>
> Have you added the Sonar Emma plugin on your Sonar platform?
>
> I added a sample project: ut-maven-emma-reuseReports.
> Could you please try again both projects?:
>
> ut-maven-emma-runTests
> ut-maven-emma-reuseReports
>
>
> Thank you
>
> Regards,
>
>
> David RACODON | SonarSource
> Senior Consultant
> http://sonarsource.com
>
>
>
> On 10 August 2012 16:51, Bartłomiej Budz <[hidden email]> wrote:
>>
>> Hi
>>
>> Firts, thanks for your reply.
>> If i have to set path for file, why on this page:
>> http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
>> i found sentence: "Tell Sonar where your code coverage report is:
>> absolute or relative path to the report file for JaCoCo or Cobertura
>> or Clover, DIRECTORY path for Emma." (last section:  "Code Coverage
>> Report")?
>> I tried to run examples. But I found that there (probably) are some
>> errors, for example:
>>
>> https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-emma-reuseReports/pom.xml
>> it's most suitable example to my problem, but in file name there is
>> "reuseReports", yet in 14h line there is:
>> <sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
>> As I think, there is big difference between reuseReports and
>> dynamicAnalysis.
>> If I understood it well, i have to reuse report, if i generate it
>> earlier then I run sonar analysis.
>> Am I right?
>>
>> Regards
>> Bart
>>
>>
>> 2012/8/10 David Racodon <[hidden email]>:
>> > Hi Bart,
>> >
>> > As mentioned in the documentation, you must set the path to the report
>> > file
>> > (not the path to the directory containing the report file). See
>> >
>> > http://docs.codehaus.org/display/SONAR/Analysis+Parameters#AnalysisParameters-UnitandIntegrationTests.
>> >
>> > Note that there are also plenty of examples for code coverage here:
>> >
>> > https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut.
>> >
>> > Regards,
>> >
>> > David RACODON | SonarSource
>> > Senior Consultant
>> > http://sonarsource.com
>> >
>> >
>> >
>> > On 10 August 2012 16:07, Bartłomiej Budz <[hidden email]> wrote:
>> >>
>> >> Hi
>> >>
>> >> I will try to describe my problem briefly.
>> >> I'm trying to deliver code coverage report to sonar. I have reports in
>> >> emma (ec and em files) and in cobertura xml file.
>> >> In both cases everything works well (project is added to sonar,
>> >> surefire reports are shown etc) but there is "-" coverage score.
>> >> In command prompt I should see 'EmmaSensor' or 'CoberturaSensor' or
>> >> sth, should I? There isn't anything indicating that emma or cobertura
>> >> plugin is used.
>> >> I tested in both with Ant and Maven, for emma and cobertura.
>> >> I tested also for jacoco, giving fake report path and it shows
>> >> JacocoSensor message that coverage is 0% (in command prompt)
>> >>
>> >> I tested with sonar 2.14, 3.1.1, emma plugin 1.0.1 and 1.2.1; windows 7
>> >> x64
>> >>
>> >> Maybe you can point me what I'm doing wrong?
>> >> Do somebody use reuseReports with emma or cobertura?
>> >>
>> >> Below you can see my build.xml and pom.xml files for emma. As for
>> >> cobertura, it's similar, only path is cobertura/coverage.xml.
>> >>
>> >> ------------------------
>> >> build.xml (ANT)
>> >> ------------------------
>> >> <?xml version="1.0"?>
>> >> <project name = "Code Coverage - ant" default = "sonar" basedir = ".">
>> >>         <target name="sonar">
>> >>                 <property name="sonar.jdbc.url"
>> >> value="jdbc:mysql://localhost:3306/sonar" />
>> >>                 <property name="sonar.jdbc.driver"
>> >> value="com.mysql.jdbc.Driver" />
>> >>                 <property name="sonar.jdbc.username" value="root" />
>> >>                 <property name="sonar.jdbc.password" value="" />
>> >>
>> >>                 <property name="sonar.sources" value="src" />
>> >>                 <property name="sonar.tests" value="tests" />
>> >>
>> >>                 <property name="sonar.dynamicAnalysis"
>> >> value="reuseReports" />
>> >>                 <property name="sonar.codeCoveragePlugin" value="emma"
>> >> />
>> >>                 <property name="sonar.surefire.reportsPath"
>> >> value="reports" />
>> >>                 <property name="sonar.emma.reportPath"
>> >> value="CodeCoverage" />
>> >>
>> >>                 <property name="sonar.importSources" value="false" />
>> >>                 <sonar:sonar key="cc.test" version="0.1"
>> >> xmlns:sonar="antlib:org.sonar.ant" />
>> >>         </target>
>> >> </project>
>> >> ------------------------
>> >> pom.xml (MAVEN)
>> >> ------------------------
>> >> <?xml version="1.0" encoding="UTF-8"?>
>> >> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> >> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> >> http://maven.apache.org/maven-v4_0_0.xsd">
>> >>   <modelVersion>4.0.0</modelVersion>
>> >>   <groupId>org.codehaus.sonar</groupId>
>> >>   <artifactId>example-ut-maven-emma-runTests</artifactId>
>> >>   <version>1.0-SNAPSHOT</version>
>> >>
>> >>   <name>Code Coverage - maven</name>
>> >>
>> >>   <properties>
>> >>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> >>         <sonar.language>java</sonar.language>
>> >>         <sonar.sources>src</sonar.sources>
>> >>         <sonar.tests>tests</sonar.tests>
>> >>
>> >>     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
>> >>     <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
>> >>     <sonar.surefire.reportsPath>reports</sonar.surefire.reportsPath>
>> >>     <sonar.emma.reportPath>CodeCoverage</sonar.emma.reportPath>
>> >>   </properties>
>> >>
>> >>   <dependencies>
>> >>     <dependency>
>> >>       <groupId>junit</groupId>
>> >>       <artifactId>junit</artifactId>
>> >>       <version>4.8.1</version>
>> >>       <scope>test</scope>
>> >>     </dependency>
>> >>   </dependencies>
>> >>
>> >>   <build>
>> >>     <plugins>
>> >>       <plugin>
>> >>         <groupId>org.apache.maven.plugins</groupId>
>> >>         <artifactId>maven-compiler-plugin</artifactId>
>> >>         <configuration>
>> >>           <source>1.5</source>
>> >>           <target>1.5</target>
>> >>         </configuration>
>> >>        </plugin>
>> >>     </plugins>
>> >>   </build>
>> >>
>> >> </project>
>> >>
>> >> Thanks,
>> >> Bart
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>     http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Bartek
>> ---------------------
>> GG: 4323480
>> Skype: bartekblues
>> www.bialka.net
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Bartek
---------------------
GG: 4323480
Skype: bartekblues
www.bialka.net

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Loading...