I am using 3.6 maven sonar plugin . While seeing with mvn sonar:sonar -X , I did not see sonar searching for failsafe report. (Finding it or not finding it is different thing )
According to this doc , I think it cannot be configured for failsafe reports for integration test.
Does mvn sonar:sonar reads failsafe reports ? If yes , how ?
I have mentioned these properties in my POM:
<sonar.jacoco.reportPath>/Users/xxx/site-order/service/target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.jacoco.reportPaths>/Users/xxx/site-order/service/target/jacoco.exec</sonar.jacoco.reportPaths>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.junit.itReportsPath>/Users/xxx/site-order/service/target/failsafe-reports</sonar.junit.itReportsPath>
I asked the same question on sonarqube forum and I got the reply that there is no such direct support in sonarqube maven plugin. Also, look here.
Related
While trying to get a Sonar execution to import a jacoco-it.exec file that was produced on a server with the jacocoagent.jar, I get the following message:
[INFO] [09:54:32.420] Sensor JaCoCoItSensor...
[INFO] [09:54:32.462] Analysing /../jenkins/jobs/../jacoco-it.exec
[INFO] [09:54:51.385] No information about coverage per test.
I have verified that the jacococ-it.exec file itself does in fact have data in it (385 MB) so it definitely is capturing information, but sonar is not able to reconcile it and I need help fixing it.
I am using:
a multi-module maven project
Sonarqube 4.5.1
Jenkins Sonar Plugin 2.1
Oracle 11g
jacoco 0.7.4
junit 4.11
Sonar creates and uses the UT file jacoco.exec just fine, but I get 0% when it displays the IT results.
[EDIT] - To further clarify
1. we have the jacocoagent.jar monitoring a jvm on an application server
2. a Jenkins job runs a group of selenium tests against the application server in #1
3. the jacoco-it.exec file is copied from the application server to a location that sonar can read. For this I am overriding the sonar it path for the jacoco plugin.
4. I get the above messages that say that sonar can't find the coverage information
The selenium tests are running as integration tests from mvn with:
mvn org.jacoco:jacoco-maven-plugin:prepare-agent-integration clean package install
Try forcing an older version (e.g. 0.7.3) of the jacoco-plugin to see if it makes any difference. This has helped for me with a similar problem. I think that there is a known issue in some version(s).
I am using cucumber framework in my project. So for the reporting part, i need have started building the cucumber reports with jenkins.
So during the setup for the trail build i am facing the below issues.
All the tests are skipped, but not executing.
Can anyone have solution. I am happy to provide any other inputs required.
When using maven and cucumber you have two options to run the tests.
With maven: mvn clean install
With cucumber:-Dtest=Runnerclass test
Where Runnerclass is the class name of runner.
Include surefire plugin in your POM.xml to pick your test. if you want to run test as well, then use mvn clean install.
Refer
How to run Cucumber JVM Test in Jenkins
I've searched through several questions related to multi-module maven projects and sonar, but those were mostly about aggregating code coverage metrics.
I have a multi-module maven project being analyzed by sonar.
If I run the analysis straight from the terminal using mvn sonar:sonar the resulting analysis will display the dependencies between the maven modules in the Design page.
However, if I run the analysis by invoking sonar-runner via Jenkins the resulting analysis will have missed the dependencies between the maven modules.
Here's a snippet of the top-level pom where I set sonar parameters:
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>
jdbc:mysql://myhost:3306/sonar?useUnicode=true&characterEncoding=utf8
</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://myhost:9999</sonar.host.url>
<sonar.java.source>1.7</sonar.java.source>
<sonar.login>jenkins</sonar.login>
<sonar.password>jenkins</sonar.password>
</properties>
</profile>
On Jenkins I configured the job to do a clean install -DskipTests=true in the build step followed by a post-build action to run Sonar.
I'm using Maven version 3.0.5, SonarQube version 3.7, Sonar Runner 2.3 and Java 1.7.0_45.
Any idea of what can I be missing in my configuration?
Indeed the SonarQube Maven bootstrapper relies on Maven to get the dependencies (either on modules or on external libraries). But SonarRunner doesn't have access to such kind of information and that's why when you analyse a project with SonarRunner you don't get any information about external dependencies.
Ok if you are using Jenkins, you need to install Sonar Plugin and set parameters. Then, you need to create a job and run maven target:
clean install
After that, mark Sonar checkbok. Run your job and you should see your code coverage.
PS: If you are using module you must have pom-root with all your modules.
I am trying to build the openNMS in eclipse helios using maven. After importing the source using "import existing maven project" i get the around 10k errors. Also i have some error in pom.xml itself, i thought fixing it could reduce the no of errors. The error in pom.xml is
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
Iam referring to http://www.opennms.org/wiki/Eclipse_and_OpenNMS for building the openNMS
Iam using maven available at http://www.eclipse.org/m2e/download/
It would help if you told us which versions of Eclipse & m2eclipse you are using, and which version of OpenNMS you are trying to build.
If all else fails, you should be able to run the Maven build from the command line. In my experience, command line builds are always more reliable and predictable.
Also make sure that you are using the instructions that match the version of OpenNMS you are trying to build.
I have run the command mvn eclipse:eclipse from cmd line which downloaded the libraries in repository then i tried to import the same source directory into eclipse only to find 10k errors
That's not what I meant.
Get out of eclipse.
Get a command prompt.
Create a new directory somewhere the is not in your eclipse workspace.
Checkout the source code.
From the command prompt run "mvn install".
And you haven't answered the questions I asked above. If you don't want to answer, fine ... but don't expect us to be able to help you.
... and i get the error as Build Failure [INFO] There are test failures.
What has happened is that the unit tests have failed, presumably because something needs to be set up to enable testing. (Perhaps, the tests are trying to talk to a database?)
There are two solutions:
Find out what is causing the tests to fail, and fix it. The surefire reports may give you some clues, and there may be some developer documentation on the test setup.
Turn off the tests by adding -Dmaven.test.skip=true to the mvn command line; see this page.
It would also be a good idea to read the Maven documentation if you haven't done so already.
You cannot combine eclipse:eclipse with the m2eclipse support. You cannot use m2eclipse with a project that uses the old resource plugin.
If you want to use eclipse:eclipse, you must use NOT use the 'maven' import from eclipse. Use just 'import existing project'. If you want to use m2eclipse, don't use eclipse:eclipse.
I had this issue with the PDFBox source, with the parent pom for that project. I put this in the pdfbox/pom.xml (just to get it to compile in eclipse at lease, which is the only thing I wanted):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<!-- had a process goal here that i removed because it was not compatible -->
</executions>
</plugin>
could you please share your way of unit testing in eclipse ? Are you using surefire plugin, m2eclipse & maven, or only testNG eclipse plugin ? Do you combine these alternatives ?
I'm using testNG + maven surefire-plugin and I had been using the testNG eclipse plugin a year ago so that I could see the results in testNG view. Then I started using Maven, but when I do "maven test phase" using m2eclipse, there is only console output and surefire reports that I can check in browser and to choose what test suite, test, or test method can be set up only via testng.xml.
On the other hand, if you use only surefire plugin and you have some specific settings regarding classpath etc., that you rely on, then running tests via testNG eclipse plugin doesn't have to be compatible with your code. Using surefire plugin, the classpath is different - target/test-classes and target/classes - than using testNG plugin, that is using the project classpath.
How do you go about what I was just talking about?
Is it possible to synchronize "maven test" using m2eclipse and surefire plugin WITH testNG eclipse plugin and view ?
EDITED: I'm also wondering, why the Maven project ("Java build path") output folder is target/classes for src/main and src/test whereas surefire plugin makes two locations target/test-classes and target/classes
Thank you very much for your your opinions.
Lisa,
You can configure the TestNG Eclipse plug-in to "watch" a test-output directory. Point it to target/surefire-reports and you should see your TestNG view update itself a few seconds after a Maven build terminates.
I see two advantages of using the surefire plugin:
Relying on the eclipse plugin only
works that way when everyone in the
project uses eclipse
Surefire plugin
can run from build that are done from
the continuous integration server
("jenkins")
And then if you have larger more long running (performance) test suites, you probably don't want to "block" your IDE while they run.
I don't think it is true what you say with the different runtime classpath, I just checked myself both maven classpath and the one when test is run via testNG eclipse plugin and both are the same. I think that m2eclipse plugin takes care of it. It's the same even for junit testing.
So afaik, there is no restriction for using testNG eclipse plugin for development and surefire plugin for instance for continuous integration as Heiko Rupp mentions. At least I have never gotten any troubles with it.
Just use both as you like, cheers !