Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

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

Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

drautureau
Hi Community,

Recently I wanted to get coverage on maven failsafe tests for all projects in my company.
Not integration tests like it is well described @ http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project (this method does not deal with failsafe plugin but use a separated sub module dedicated to IT tests which are run with surefire plugin), but tests executed by failsafe plugin (so I won't use the unit/integration terminology in this email but surefire/failsafe).

So I modified the parent POM used for all projects similar to the attached project:
1/ need to set <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> in the configuration of the failsafe plugin to get the report in the
"Unit Tests Coverage" widget
2/ need to set the property <sonar.phase>post-integration-test</sonar.phase> to execute failsafe tests during Sonar analyse
3/ need to force jacoco-maven-plugin:prepare-agent for failsafe tests

All these modification are activated by the usage of a profile which is run only for Sonar analyses (in the attached project: jacoco-for-failsafe).

Doing this, surefire tests are running twice during Sonar analyses which was not the expected behavior.
And on some projects (I guess that is comes when tests are not properly isolated), the reports of the executed tests and therefore the coverage is not properly computed.

So my question are:
* Is it normal to execute surefire tests twice in Sonar analyses when we set the property sonar.phase to post-integration-test ?
* Is it plan to integrate failsafe plugin in the Maven Sonar plugin? which may fix the above issue?

thanks

PS1: I don't want to compute coverage reports during CI builds -using reuseReports property- (to keep the builds fast) but want it for nightly builds
PS2: Using maven 3.0.5, Jenkins 1.529, Sonar Jenkins plugin 2.1, Sonar post build action, no overwriting of the version of sonar-maven-plugin


 

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

    http://xircles.codehaus.org/manage_email

my-app.zip (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

Freddy Mallet
Hello,

For me this unexpected behavior is due to a design issue :
  • You don't want SonarQube to execute unit tests because you've a specific configuration based on Failsafe plugin
  • But you're using the 'sonar.phase' phase to execute the failsafe plugin during SonarQube execution
What happens ?
  • SonarQube tries to execute unit tests -> 1st execution
  • The dependency on Maven 'post-integration-test' leads to execute failsafe plugin -> 2nd execution
The only way to fix this :
  • Ask SonarQube to not execute unit tests -> sonar.reuseReports = true
  • I think it would be better to execute the Jacoco report before the execution of SonarQube
++


-----
SonarQube for Continuous Inspection


On Tue, Sep 17, 2013 at 3:25 PM, <[hidden email]> wrote:
Hi Community,

Recently I wanted to get coverage on maven failsafe tests for all projects in my company.
Not integration tests like it is well described @ http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project (this method does not deal with failsafe plugin but use a separated sub module dedicated to IT tests which are run with surefire plugin), but tests executed by failsafe plugin (so I won't use the unit/integration terminology in this email but surefire/failsafe).

So I modified the parent POM used for all projects similar to the attached project:
1/ need to set <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> in the configuration of the failsafe plugin to get the report in the
"Unit Tests Coverage" widget
2/ need to set the property <sonar.phase>post-integration-test</sonar.phase> to execute failsafe tests during Sonar analyse
3/ need to force jacoco-maven-plugin:prepare-agent for failsafe tests

All these modification are activated by the usage of a profile which is run only for Sonar analyses (in the attached project: jacoco-for-failsafe).

Doing this, surefire tests are running twice during Sonar analyses which was not the expected behavior.
And on some projects (I guess that is comes when tests are not properly isolated), the reports of the executed tests and therefore the coverage is not properly computed.

So my question are:
* Is it normal to execute surefire tests twice in Sonar analyses when we set the property sonar.phase to post-integration-test ?
* Is it plan to integrate failsafe plugin in the Maven Sonar plugin? which may fix the above issue?

thanks

PS1: I don't want to compute coverage reports during CI builds -using reuseReports property- (to keep the builds fast) but want it for nightly builds
PS2: Using maven 3.0.5, Jenkins 1.529, Sonar Jenkins plugin 2.1, Sonar post build action, no overwriting of the version of sonar-maven-plugin


 

---------------------------------------------------------------------
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: Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

drautureau
Hi Freddy,

thanks for your answer and see my answers inline:

For me this unexpected behavior is due to a design issue :
    • You don't want SonarQube to execute unit tests because you've a specific configuration based on Failsafe plugin
No I do want SonarQube to execute unit tests (to get the coverage); I want both (the coverage for failsafe tests as well) :)
And the specific configuration of the failsafe plugin is the only way I found to get the report of failsafe tests in the "Unit Tests coverage' widget
    • But you're using the 'sonar.phase' phase to execute the failsafe plugin during SonarQube execution
Yes, that's the goal

What happens ?
    • SonarQube tries to execute unit tests -> 1st execution
    • The dependency on Maven 'post-integration-test' leads to execute failsafe plugin -> 2nd execution
I was expecting the same behavior than if I were using the maven's phase integration-test (should have tell that in the previous mail)
  • mvn test execute surefire tests
  • mvn integration-test execute surefire and failsafe tests

The only way to fix this :
    • Ask SonarQube to not execute unit tests -> sonar.reuseReports = true
    • I think it would be better to execute the Jacoco report before the execution of SonarQube
That's something I would like to avoid to keep CI builds fast and dedicate code inspection for nightly builds.

So the question I want to raise is related to Sonar and Maven integration using the property sonar.phase.
IMHO, it should act as Maven phases: using sonar.phase=post-integration should run surefire tests (1 time) + failsafe tests 

What's your opinion ?




De: "Freddy Mallet" <[hidden email]>
À: "user" <[hidden email]>
Envoyé: Mercredi 18 Septembre 2013 11:06:21
Objet: Re: [sonar-user] Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

Hello,

For me this unexpected behavior is due to a design issue :
  • You don't want SonarQube to execute unit tests because you've a specific configuration based on Failsafe plugin
  • But you're using the 'sonar.phase' phase to execute the failsafe plugin during SonarQube execution
What happens ?
  • SonarQube tries to execute unit tests -> 1st execution
  • The dependency on Maven 'post-integration-test' leads to execute failsafe plugin -> 2nd execution
The only way to fix this :
  • Ask SonarQube to not execute unit tests -> sonar.reuseReports = true
  • I think it would be better to execute the Jacoco report before the execution of SonarQube
++


-----
SonarQube for Continuous Inspection


On Tue, Sep 17, 2013 at 3:25 PM, <[hidden email]> wrote:
Hi Community,

Recently I wanted to get coverage on maven failsafe tests for all projects in my company.
Not integration tests like it is well described @ http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project (this method does not deal with failsafe plugin but use a separated sub module dedicated to IT tests which are run with surefire plugin), but tests executed by failsafe plugin (so I won't use the unit/integration terminology in this email but surefire/failsafe).

So I modified the parent POM used for all projects similar to the attached project:
1/ need to set <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> in the configuration of the failsafe plugin to get the report in the
"Unit Tests Coverage" widget
2/ need to set the property <sonar.phase>post-integration-test</sonar.phase> to execute failsafe tests during Sonar analyse
3/ need to force jacoco-maven-plugin:prepare-agent for failsafe tests

All these modification are activated by the usage of a profile which is run only for Sonar analyses (in the attached project: jacoco-for-failsafe).

Doing this, surefire tests are running twice during Sonar analyses which was not the expected behavior.
And on some projects (I guess that is comes when tests are not properly isolated), the reports of the executed tests and therefore the coverage is not properly computed.

So my question are:
* Is it normal to execute surefire tests twice in Sonar analyses when we set the property sonar.phase to post-integration-test ?
* Is it plan to integrate failsafe plugin in the Maven Sonar plugin? which may fix the above issue?

thanks

PS1: I don't want to compute coverage reports during CI builds -using reuseReports property- (to keep the builds fast) but want it for nightly builds
PS2: Using maven 3.0.5, Jenkins 1.529, Sonar Jenkins plugin 2.1, Sonar post build action, no overwriting of the version of sonar-maven-plugin


 

---------------------------------------------------------------------
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: Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

ale.nadasan
This post has NOT been accepted by the mailing list yet.
In reply to this post by Freddy Mallet
Hello,

I'm new to Sonar and facing the same issue related to test executing multiple times (three times). Where should I add sonar.reuseReports = true ?

Currently, my Selenium tests are running in Jenkins, and Sonar plugin is added as a post build step.
After the tests run for the first time, the tests are recorded in the DB and the following actions happen:

 --- sonar-maven-plugin:2.2:sonar (default-cli) @ selTests ---
13:02:16 [INFO] SonarQube version: 3.7.4
13:02:17 INFO: Default locale: "en_US", source code encoding: "UTF-8"
13:02:17 INFO: Work directory: c:\jenkins\workspace\Test Job\tests\target\sonar
13:02:17 INFO: SonarQube Server 3.7.4
13:02:18 [INFO] [13:01:52.515] Load batch settings
13:02:18 [INFO] [13:01:52.765] User cache: C:\Documents and Settings\QA\.sonar\cache
13:02:18 [INFO] [13:01:52.765] Install plugins
13:02:19 [INFO] [13:01:53.531] Install JDBC driver
13:02:19 [INFO] [13:01:53.546] Create JDBC datasource for jdbc:mysql://192.168.1.1:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
13:02:22 [INFO] [13:01:56.062] Initializing Hibernate
13:02:28 [INFO] [13:02:02.015] Load project settings
13:02:28 [INFO] [13:02:02.062] Apply project exclusions
13:02:28 [INFO] [13:02:02.343] -------------  Scan selTests
13:02:28 [INFO] [13:02:02.359] Load module settings
13:02:29 [INFO] [13:02:03.015] Quality profile : [name=Sonar way,language=java]
13:02:29 [INFO] [13:02:03.078] Excluded tests:
13:02:29 [INFO] [13:02:03.078]   **/package-info.java
13:02:29 [INFO] [13:02:03.140] Configure Maven plugins
13:02:29 [INFO] [13:02:03.265] Compare to previous analysis (2014-06-04)
13:02:29 [INFO] [13:02:03.328] Compare over 30 days (2014-05-05, analysis of 2014-05-28 11:52:40.0)
13:02:29 [INFO] [13:02:03.359] Compare to previous version
13:02:29 [INFO] [13:02:03.578] Deleting C:\jenkins\workspace\Test Job\tests\target\jacoco.exec
13:02:29 [INFO] [13:02:03.625] JaCoCo agent (version 0.6.2.201302030002) extracted: C:\DOCUME~1\QA\LOCALS~1\Temp\jacocoagent2571607357694117411.jar
13:02:29 [INFO] [13:02:03.625] JVM options: -javaagent:C:\DOCUME~1\QA\LOCALS~1\Temp\jacocoagent2571607357694117411.jar=destfile=target/jacoco.exec,excludes=*_javassist_*
13:02:29 [INFO] [13:02:03.734] Execute maven plugin maven-surefire-plugin...
13:02:29 [INFO] [13:02:03.734] Execute org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test..

And the tests run again.... The next step after that:

[13:03:48.468] Execute org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test done: 104734 ms
13:04:14 [INFO] [13:03:48.468] Execute maven plugin maven-surefire-plugin done: 104734 ms
13:04:14 [INFO] [13:03:48.468] Initializer JacocoMavenInitializer...
13:04:14 [INFO] [13:03:48.468] Initializer JacocoMavenInitializer done: 0 ms
13:04:14 [INFO] [13:03:48.468] Base dir: c:\jenkins\workspace\Test Job\tests
13:04:14 [INFO] [13:03:48.468] Working dir: c:\jenkins\workspace\Test Job\tests\target\sonar
13:04:14 [INFO] [13:03:48.468] Test dirs: c:\jenkins\workspace\Test Job\tests\src\test\java
13:04:14 [INFO] [13:03:48.468] Source encoding: UTF-8, default locale: en_US
13:04:14 [INFO] [13:03:48.531] Sensor JavaSourceImporter...
13:04:16 [INFO] [13:03:50.125] Sensor JavaSourceImporter done: 1594 ms
13:04:16 [INFO] [13:03:50.125] Sensor JavaSquidSensor...
13:04:16 [INFO] [13:03:50.125] Sensor JavaSquidSensor done: 0 ms
13:04:16 [INFO] [13:03:50.125] Sensor JaCoCoItSensor...
13:04:16 [INFO] [13:03:50.140] Project coverage is set to 0% since there is no directories with classes.
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoItSensor done: 15 ms
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoOverallSensor...
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoOverallSensor done: 0 ms
13:04:16 [INFO] [13:03:50.140] Sensor SurefireSensor...
13:04:16 [INFO] [13:03:50.140] parsing c:\jenkins\workspace\Test Job\tests\target\surefire-reports
13:04:16 [INFO] [13:03:50.578] Sensor SurefireSensor done: 438 ms
13:04:16 [INFO] [13:03:50.578] Sensor CpdSensor...
13:04:16 [INFO] [13:03:50.578] SonarEngine is used
13:04:16 [INFO] [13:03:50.578] Sensor CpdSensor done: 0 ms
13:04:16 [INFO] [13:03:50.578] Sensor InitialOpenIssuesSensor...
13:04:16 [INFO] [13:03:50.578] Sensor InitialOpenIssuesSensor done: 0 ms
13:04:16 [INFO] [13:03:50.578] Sensor ProfileSensor...
13:04:16 [INFO] [13:03:50.812] Sensor ProfileSensor done: 234 ms
13:04:16 [INFO] [13:03:50.812] Sensor ProfileEventsSensor...
13:04:16 [INFO] [13:03:50.859] Sensor ProfileEventsSensor done: 47 ms
13:04:16 [INFO] [13:03:50.859] Sensor ProjectLinksSensor...
13:04:16 [INFO] [13:03:50.875] Sensor ProjectLinksSensor done: 16 ms
13:04:16 [INFO] [13:03:50.875] Sensor VersionEventsSensor...
13:04:16 [INFO] [13:03:50.906] Sensor VersionEventsSensor done: 31 ms
13:04:16 [INFO] [13:03:50.906] Sensor Maven dependencies...
13:04:18 [INFO] [13:03:52.156] Sensor Maven dependencies done: 1250 ms
13:04:18 [INFO] [13:03:52.156] Sensor JaCoCoSensor...
13:04:18 [INFO] [13:03:52.171] Project coverage is set to 0% since there is no directories with classes.
13:04:18 [INFO] [13:03:52.171] Sensor JaCoCoSensor done: 15 ms
13:04:18 [INFO] [13:03:52.640] Execute decorators...
13:04:20 [INFO] [13:03:54.656] Store results in database
13:04:20 [INFO] [13:03:55.078] ANALYSIS SUCCESSFUL
13:04:21 [INFO] [13:03:55.125] Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
13:04:21 [INFO] [13:03:55.125] Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
13:04:21 [INFO] [13:03:55.234] Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per day between 2014-05-07 and 2014-06-03
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per week between 2013-06-05 and 2014-05-07
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per month between 2009-06-10 and 2013-06-05
13:04:21 [INFO] [13:03:55.250] -> Delete data prior to: 2009-06-10
13:04:21 [INFO] [13:03:55.265] -> Clean selTests [id=2]
13:04:21 [INFO] [13:03:55.265] <- Clean snapshot 225

And the tests are running for one last time. Meanwhile, when I go to Sonar server, I can't see any changes. from the previous builds, and I get Issues: 0 and Unit tests Coverage: - . Can you please help with the configuration?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

ale.nadasan
Hello,

I'm new to Sonar and facing the same issue related to test executing multiple times (three times). Where should I add sonar.reuseReports = true ?

Currently, my Selenium tests are running in Jenkins, and Sonar plugin is added as a post build step.
After the tests run for the first time, the tests are recorded in the DB and the following actions happen:

 --- sonar-maven-plugin:2.2:sonar (default-cli) @ selTests ---
13:02:16 [INFO] SonarQube version: 3.7.4
13:02:17 INFO: Default locale: "en_US", source code encoding: "UTF-8"
13:02:17 INFO: Work directory: c:\jenkins\workspace\Test Job\tests\target\sonar
13:02:17 INFO: SonarQube Server 3.7.4
13:02:18 [INFO] [13:01:52.515] Load batch settings
13:02:18 [INFO] [13:01:52.765] User cache: C:\Documents and Settings\QA\.sonar\cache
13:02:18 [INFO] [13:01:52.765] Install plugins
13:02:19 [INFO] [13:01:53.531] Install JDBC driver
13:02:19 [INFO] [13:01:53.546] Create JDBC datasource for jdbc:mysql://192.168.1.1:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
13:02:22 [INFO] [13:01:56.062] Initializing Hibernate
13:02:28 [INFO] [13:02:02.015] Load project settings
13:02:28 [INFO] [13:02:02.062] Apply project exclusions
13:02:28 [INFO] [13:02:02.343] -------------  Scan selTests
13:02:28 [INFO] [13:02:02.359] Load module settings
13:02:29 [INFO] [13:02:03.015] Quality profile : [name=Sonar way,language=java]
13:02:29 [INFO] [13:02:03.078] Excluded tests:
13:02:29 [INFO] [13:02:03.078]   **/package-info.java
13:02:29 [INFO] [13:02:03.140] Configure Maven plugins
13:02:29 [INFO] [13:02:03.265] Compare to previous analysis (2014-06-04)
13:02:29 [INFO] [13:02:03.328] Compare over 30 days (2014-05-05, analysis of 2014-05-28 11:52:40.0)
13:02:29 [INFO] [13:02:03.359] Compare to previous version
13:02:29 [INFO] [13:02:03.578] Deleting C:\jenkins\workspace\Test Job\tests\target\jacoco.exec
13:02:29 [INFO] [13:02:03.625] JaCoCo agent (version 0.6.2.201302030002) extracted: C:\DOCUME~1\QA\LOCALS~1\Temp\jacocoagent2571607357694117411.jar
13:02:29 [INFO] [13:02:03.625] JVM options: -javaagent:C:\DOCUME~1\QA\LOCALS~1\Temp\jacocoagent2571607357694117411.jar=destfile=target/jacoco.exec,excludes=*_javassist_*
13:02:29 [INFO] [13:02:03.734] Execute maven plugin maven-surefire-plugin...
13:02:29 [INFO] [13:02:03.734] Execute org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test..

And the tests run again.... The next step after that:

[13:03:48.468] Execute org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test done: 104734 ms
13:04:14 [INFO] [13:03:48.468] Execute maven plugin maven-surefire-plugin done: 104734 ms
13:04:14 [INFO] [13:03:48.468] Initializer JacocoMavenInitializer...
13:04:14 [INFO] [13:03:48.468] Initializer JacocoMavenInitializer done: 0 ms
13:04:14 [INFO] [13:03:48.468] Base dir: c:\jenkins\workspace\Test Job\tests
13:04:14 [INFO] [13:03:48.468] Working dir: c:\jenkins\workspace\Test Job\tests\target\sonar
13:04:14 [INFO] [13:03:48.468] Test dirs: c:\jenkins\workspace\Test Job\tests\src\test\java
13:04:14 [INFO] [13:03:48.468] Source encoding: UTF-8, default locale: en_US
13:04:14 [INFO] [13:03:48.531] Sensor JavaSourceImporter...
13:04:16 [INFO] [13:03:50.125] Sensor JavaSourceImporter done: 1594 ms
13:04:16 [INFO] [13:03:50.125] Sensor JavaSquidSensor...
13:04:16 [INFO] [13:03:50.125] Sensor JavaSquidSensor done: 0 ms
13:04:16 [INFO] [13:03:50.125] Sensor JaCoCoItSensor...
13:04:16 [INFO] [13:03:50.140] Project coverage is set to 0% since there is no directories with classes.
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoItSensor done: 15 ms
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoOverallSensor...
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoOverallSensor done: 0 ms
13:04:16 [INFO] [13:03:50.140] Sensor SurefireSensor...
13:04:16 [INFO] [13:03:50.140] parsing c:\jenkins\workspace\Test Job\tests\target\surefire-reports
13:04:16 [INFO] [13:03:50.578] Sensor SurefireSensor done: 438 ms
13:04:16 [INFO] [13:03:50.578] Sensor CpdSensor...
13:04:16 [INFO] [13:03:50.578] SonarEngine is used
13:04:16 [INFO] [13:03:50.578] Sensor CpdSensor done: 0 ms
13:04:16 [INFO] [13:03:50.578] Sensor InitialOpenIssuesSensor...
13:04:16 [INFO] [13:03:50.578] Sensor InitialOpenIssuesSensor done: 0 ms
13:04:16 [INFO] [13:03:50.578] Sensor ProfileSensor...
13:04:16 [INFO] [13:03:50.812] Sensor ProfileSensor done: 234 ms
13:04:16 [INFO] [13:03:50.812] Sensor ProfileEventsSensor...
13:04:16 [INFO] [13:03:50.859] Sensor ProfileEventsSensor done: 47 ms
13:04:16 [INFO] [13:03:50.859] Sensor ProjectLinksSensor...
13:04:16 [INFO] [13:03:50.875] Sensor ProjectLinksSensor done: 16 ms
13:04:16 [INFO] [13:03:50.875] Sensor VersionEventsSensor...
13:04:16 [INFO] [13:03:50.906] Sensor VersionEventsSensor done: 31 ms
13:04:16 [INFO] [13:03:50.906] Sensor Maven dependencies...
13:04:18 [INFO] [13:03:52.156] Sensor Maven dependencies done: 1250 ms
13:04:18 [INFO] [13:03:52.156] Sensor JaCoCoSensor...
13:04:18 [INFO] [13:03:52.171] Project coverage is set to 0% since there is no directories with classes.
13:04:18 [INFO] [13:03:52.171] Sensor JaCoCoSensor done: 15 ms
13:04:18 [INFO] [13:03:52.640] Execute decorators...
13:04:20 [INFO] [13:03:54.656] Store results in database
13:04:20 [INFO] [13:03:55.078] ANALYSIS SUCCESSFUL
13:04:21 [INFO] [13:03:55.125] Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
13:04:21 [INFO] [13:03:55.125] Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
13:04:21 [INFO] [13:03:55.234] Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per day between 2014-05-07 and 2014-06-03
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per week between 2013-06-05 and 2014-05-07
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per month between 2009-06-10 and 2013-06-05
13:04:21 [INFO] [13:03:55.250] -> Delete data prior to: 2009-06-10
13:04:21 [INFO] [13:03:55.265] -> Clean selTests [id=2]
13:04:21 [INFO] [13:03:55.265] <- Clean snapshot 225

And the tests are running for one last time. Meanwhile, when I go to Sonar server, I can't see any changes. from the previous builds, and I get Issues: 0 and Unit tests Coverage: - . Can you please help with the configuration?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Maven Sonar plugin execute surefire tests twice when setting the property sonar.phase=post-integration-test

Freddy Mallet
Hello Ale, 

It's never a good idea to reactivate an old thread of discussion because most of the time it's misleading.

If my understanding is correct your question is : "How can I prevent SonarQube from executing unit tests and so how can I configure SonarQube to reuse unit test reports ?", Am I correct ?

With a standard Maven configuration, the following command should do the job:

mvn sonar:sonar -Dsonar.dynamicAnalysis=reuseReports

++

-----
SonarQube for Continuous Inspection


On Tue, Jun 3, 2014 at 1:21 PM, ale.nadasan <[hidden email]> wrote:
Hello,

I'm new to Sonar and facing the same issue related to test executing
multiple times (three times). Where should I add sonar.reuseReports = true ?

Currently, my Selenium tests are running in Jenkins, and Sonar plugin is
added as a post build step.
After the tests run for the first time, the tests are recorded in the DB and
the following actions happen:

 --- sonar-maven-plugin:2.2:sonar (default-cli) @ selTests ---
13:02:16 [INFO] SonarQube version: 3.7.4
13:02:17 INFO: Default locale: "en_US", source code encoding: "UTF-8"
13:02:17 INFO: Work directory: c:\jenkins\workspace\Test
Job\tests\target\sonar
13:02:17 INFO: SonarQube Server 3.7.4
13:02:18 [INFO] [13:01:52.515] Load batch settings
13:02:18 [INFO] [13:01:52.765] User cache: C:\Documents and
Settings\QA\.sonar\cache
13:02:18 [INFO] [13:01:52.765] Install plugins
13:02:19 [INFO] [13:01:53.531] Install JDBC driver
13:02:19 [INFO] [13:01:53.546] Create JDBC datasource for
jdbc:mysql://192.168.1.1:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
13:02:22 [INFO] [13:01:56.062] Initializing Hibernate
13:02:28 [INFO] [13:02:02.015] Load project settings
13:02:28 [INFO] [13:02:02.062] Apply project exclusions
13:02:28 [INFO] [13:02:02.343] -------------  Scan selTests
13:02:28 [INFO] [13:02:02.359] Load module settings
13:02:29 [INFO] [13:02:03.015] Quality profile : [name=Sonar
way,language=java]
13:02:29 [INFO] [13:02:03.078] Excluded tests:
13:02:29 [INFO] [13:02:03.078]   **/package-info.java
13:02:29 [INFO] [13:02:03.140] Configure Maven plugins
13:02:29 [INFO] [13:02:03.265] Compare to previous analysis (2014-06-04)
13:02:29 [INFO] [13:02:03.328] Compare over 30 days (2014-05-05, analysis of
2014-05-28 11:52:40.0)
13:02:29 [INFO] [13:02:03.359] Compare to previous version
13:02:29 [INFO] [13:02:03.578] Deleting C:\jenkins\workspace\Test
Job\tests\target\jacoco.exec
13:02:29 [INFO] [13:02:03.625] JaCoCo agent (version 0.6.2.201302030002)
extracted: C:\DOCUME~1\QA\LOCALS~1\Temp\jacocoagent2571607357694117411.jar
13:02:29 [INFO] [13:02:03.625] JVM options:
-javaagent:C:\DOCUME~1\QA\LOCALS~1\Temp\jacocoagent2571607357694117411.jar=destfile=target/jacoco.exec,excludes=*_javassist_*
13:02:29 [INFO] [13:02:03.734] Execute maven plugin maven-surefire-plugin...
13:02:29 [INFO] [13:02:03.734] Execute
org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test..

And the tests run again.... The next step after that:

[13:03:48.468] Execute
org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test done: 104734 ms
13:04:14 [INFO] [13:03:48.468] Execute maven plugin maven-surefire-plugin
done: 104734 ms
13:04:14 [INFO] [13:03:48.468] Initializer JacocoMavenInitializer...
13:04:14 [INFO] [13:03:48.468] Initializer JacocoMavenInitializer done: 0 ms
13:04:14 [INFO] [13:03:48.468] Base dir: c:\jenkins\workspace\Test Job\tests
13:04:14 [INFO] [13:03:48.468] Working dir: c:\jenkins\workspace\Test
Job\tests\target\sonar
13:04:14 [INFO] [13:03:48.468] Test dirs: c:\jenkins\workspace\Test
Job\tests\src\test\java
13:04:14 [INFO] [13:03:48.468] Source encoding: UTF-8, default locale: en_US
13:04:14 [INFO] [13:03:48.531] Sensor JavaSourceImporter...
13:04:16 [INFO] [13:03:50.125] Sensor JavaSourceImporter done: 1594 ms
13:04:16 [INFO] [13:03:50.125] Sensor JavaSquidSensor...
13:04:16 [INFO] [13:03:50.125] Sensor JavaSquidSensor done: 0 ms
13:04:16 [INFO] [13:03:50.125] Sensor JaCoCoItSensor...
13:04:16 [INFO] [13:03:50.140] Project coverage is set to 0% since there is
no directories with classes.
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoItSensor done: 15 ms
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoOverallSensor...
13:04:16 [INFO] [13:03:50.140] Sensor JaCoCoOverallSensor done: 0 ms
13:04:16 [INFO] [13:03:50.140] Sensor SurefireSensor...
13:04:16 [INFO] [13:03:50.140] parsing c:\jenkins\workspace\Test
Job\tests\target\surefire-reports
13:04:16 [INFO] [13:03:50.578] Sensor SurefireSensor done: 438 ms
13:04:16 [INFO] [13:03:50.578] Sensor CpdSensor...
13:04:16 [INFO] [13:03:50.578] SonarEngine is used
13:04:16 [INFO] [13:03:50.578] Sensor CpdSensor done: 0 ms
13:04:16 [INFO] [13:03:50.578] Sensor InitialOpenIssuesSensor...
13:04:16 [INFO] [13:03:50.578] Sensor InitialOpenIssuesSensor done: 0 ms
13:04:16 [INFO] [13:03:50.578] Sensor ProfileSensor...
13:04:16 [INFO] [13:03:50.812] Sensor ProfileSensor done: 234 ms
13:04:16 [INFO] [13:03:50.812] Sensor ProfileEventsSensor...
13:04:16 [INFO] [13:03:50.859] Sensor ProfileEventsSensor done: 47 ms
13:04:16 [INFO] [13:03:50.859] Sensor ProjectLinksSensor...
13:04:16 [INFO] [13:03:50.875] Sensor ProjectLinksSensor done: 16 ms
13:04:16 [INFO] [13:03:50.875] Sensor VersionEventsSensor...
13:04:16 [INFO] [13:03:50.906] Sensor VersionEventsSensor done: 31 ms
13:04:16 [INFO] [13:03:50.906] Sensor Maven dependencies...
13:04:18 [INFO] [13:03:52.156] Sensor Maven dependencies done: 1250 ms
13:04:18 [INFO] [13:03:52.156] Sensor JaCoCoSensor...
13:04:18 [INFO] [13:03:52.171] Project coverage is set to 0% since there is
no directories with classes.
13:04:18 [INFO] [13:03:52.171] Sensor JaCoCoSensor done: 15 ms
13:04:18 [INFO] [13:03:52.640] Execute decorators...
13:04:20 [INFO] [13:03:54.656] Store results in database
13:04:20 [INFO] [13:03:55.078] ANALYSIS SUCCESSFUL
13:04:21 [INFO] [13:03:55.125] Executing post-job class
org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
13:04:21 [INFO] [13:03:55.125] Executing post-job class
org.sonar.plugins.core.batch.IndexProjectPostJob
13:04:21 [INFO] [13:03:55.234] Executing post-job class
org.sonar.plugins.dbcleaner.ProjectPurgePostJob
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per day between
2014-05-07 and 2014-06-03
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per week between
2013-06-05 and 2014-05-07
13:04:21 [INFO] [13:03:55.250] -> Keep one snapshot per month between
2009-06-10 and 2013-06-05
13:04:21 [INFO] [13:03:55.250] -> Delete data prior to: 2009-06-10
13:04:21 [INFO] [13:03:55.265] -> Clean selTests [id=2]
13:04:21 [INFO] [13:03:55.265] <- Clean snapshot 225

And the tests are running for one last time. Meanwhile, when I go to Sonar
server, I can't see any changes. from the previous builds, and I get Issues:
0 and Unit tests Coverage: - . Can you please help with the configuration?



--
View this message in context: http://sonarqube.15.x6.nabble.com/Maven-Sonar-plugin-execute-surefire-tests-twice-when-setting-the-property-sonar-phase-post-integratit-tp5017101p5025372.html
Sent from the SonarQube Users mailing list archive at Nabble.com.

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

    http://xircles.codehaus.org/manage_email



Loading...