I have integrated SOAPUI with Maven so that my test cases can be executed with Maven build.
It works fine.
But this integration does not create any formatted report which i can refer to know the test results, like an HTML output.
For the same I added a plugin in my POM.XML (shown below)
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</reporting>
This creates the report, but it does it for all the junit test cases which are in my project.
I can not see any report on the SOAPUI test case.
How can I make the Surefire report contain the SoapUI test results?
Just got it working in my setup.
The solution is "maven-surefire-report-plugin" converts the "TEST*.xml" in to HTML format which is placed in "/targets/surefire-report".So make sure "soapui-maven-plugin" is placing the output in of the "soapui-maven-plugin" in "/targets/surefire-report" directory.
Please see the sample below
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.1.2</version>
<executions>
<execution>
<phase>test</phase>
<goals><goal>test</goal></goals>
<configuration>
<projectFile>${baseDirectory}/src/test/integration/resources/Mobile-Ads-soapui-project.xml</projectFile>
<iface>mobileAdsService</iface>
<outputFolder>${baseDirectory}/target/surefire-reports/</outputFolder>
<junitReport>true</junitReport>
<exportwAll>true</exportwAll>
<printReport>true</printReport>
<testFailIgnore>false</testFailIgnore>
</configuration>
</execution>
</executions>
</plugin>
Related
I am trying to integrate my code coverage into the sonar but it shows 0.
I have integrated jacoco as below to my pom but, it still shows the code coverage as zero.
I have only used the pom file from this repository, what other configuration should I work in order to have code coverage ?
What would be other parameters should I possibly add?
https://github.com/daniel-frak/keycloak-user-migration/blob/master/pom.xml
Thanks.
Full repo:
https://github.com/daniel-frak/keycloak-user-migration
There are a number of things that can cause this.
The first thing you should do is examine the workspace to see if the Jacoco plugin wrote its output files anywhere in the "target" tree. It will generate a data file in one or more formats, but it will also generate an html tree, with an "index.html" in the root. You can visit that file, and it will show your coverage results.
If you don't find those files, then either your jacoco plugin is not properly integrated with your surefire plugin, or you simply didn't run your unit tests in the build (don't laugh, I've seen people do this).
The "integration" is done by telling Jacoco what variable to put the required command line into, and telling Surefire to use that variable.
Here is a sample jacoco plugin definition:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>${jacoco.path}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Note the reference to "surefireArgLine". Here is the Surefire definition that goes with that:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
We also combine this with these property settings:
<jacoco.path>${basedir}/target/jacoco_report</jacoco.path>
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/target/jacoco_report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
I am running testng.xml file using POM.xml by adding compiler and surefire plugins. It runs test but the sequence of tests is not as expected.
I have 10 classes mentioned in testng.xml and it runs in that sequence when i run through testng.xml. But when running through POM.xml the sequence goes like; first it runs all the 0 priority tests mentioned in all classes, then 1 priority tests and so on. It should run tests according to the classes sequence mentioned in testng.xml.
Any quick help will be much appreciated.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${jdk.level}</source>
<target>${jdk.level}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
under testng dependency the scope tag needed to be changed to compile from test and it resolved the issue as it needed to compile the build after adding plugins.
It resolved the issue.
I've done a lot of work in the past writing unit tests that run in "conventional" Maven builds,
using JUnit and Mockito (and PowerMock). I'm now working on an Eclipse plugin codebase, which builds with Maven Tycho.
Overall, it's a multiproject build, but I'm only adding unit tests to one of the plugin projects (for now).
I've heard of tycho-surefire, but that seems pretty complicated, and it really sounds more like it supports integration tests instead of unit tests. I'm guessing I'll probably have no choice but to use this, but so far I haven't tried to integrate it.
I tried getting the JUnit and Mockito artifacts from Maven, and then using the maven-dependency-plugin to get the artifacts available to be referenced in the Bundle-Classpath property of the manifest.
When I run the build, the tycho-compiler-plugin I see it compiling 105 source files, which includes all of the classes in src/main/java and src/test/java.
It fails to compile the test class because it can't find the Mockito classes, even though when I run the build with -X, it shows the mockito-all artifact in the dependency tree.
What can I do here?
After a lot of painful Maven trial & error I struggled across this website, which provides a surprisingly easy way to use unit-tests in a Maven-Tycho setup.
Here, the important parts of the pom.xml when using JUnit (probably looks similar for Mockito):
<testSourceDirectory>src/test/java</testSourceDirectory>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>compiletests</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Name all your tests in a way so that they end with *Test.java. Run mvn test in order to execute all available unit-tests.
You have to use junit and Mockito as osgi bundles
I think this Question answered detailed here
I hope this helps.
I am trying to copy a test run report generated by maven to a different location on the same machine. I have written the code to copy the report in the teardown method but currently the problem is that the report is generated by maven at the end of the test run hence the tear down method is not able to find the report. Please let me know where exactly the code for copying the report should be written
You can configure the Surefire Report plugin to generate the report in a different place:
<configuration>
<outputDirectory>/some/absolute/path</outputDirectory>
</configuration>
See http://maven.apache.org/surefire/maven-surefire-report-plugin/examples/report-custom-location.html for details.
If you want the report in both places, the most simple solution might be to run the report plugin twice by creating two executions.
Add a plugin with a shell command to copy
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>copy_report</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>/bin/cp</executable>
<workingDirectory>${project.build.directory}/your/output/dir</workingDirectory>
<arguments>
<argument>your_report.txt</argument>
<argument>/path/to/the/other/location</argument>
</arguments>
</configuration>
</plugin>
I am trying to integrate FindBugs in a maven project. Does anyone have a sample pom.xml generating a simple findbug HTML report in target? Is it possible to generate this report without having to run site:site?
Findbugs jar contains 5 XSLT transformations that can be used to convert hard to read XML to easy to read HTML so we can use xml-maven-plugin plugin to execute transformation and here is the configuration:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>findbug</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<findbugsXmlOutputDirectory>
${project.build.directory}/findbugs
</findbugsXmlOutputDirectory>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>${project.build.directory}/findbugs</dir>
<outputDir>${project.build.directory}/findbugs</outputDir>
<stylesheet>fancy-hist.xsl</stylesheet>
<!--<stylesheet>default.xsl</stylesheet>-->
<!--<stylesheet>plain.xsl</stylesheet>-->
<!--<stylesheet>fancy.xsl</stylesheet>-->
<!--<stylesheet>summary.xsl</stylesheet>-->
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
To get the report just execute mvn clean install.
The above code snippet contains all 5 possible transformations so try them all and hopefully you will find one you like.
I tried it with maven 3 and Finbugs 2.0
Check out Sonar. It's an open-source, stand-alone, web service that you "submit" your code to and it produces beautiful HTML reports on all kinds of code metrics. It also keeps a history of builds. And best of all, you don't have to modify your builds or poms!
There is a maven goal for it too: sonar:sonar. Jenkins (previously Hudson) has a plugin for it, so it's totally painless if you use that for your CI.
Check it out - you won't be sorry!