I am using Mockito and Power Mockito in my unit test cases. I am able to generate the jacoco report when I run the profile code-coverage but
I am getting error when I try to generate Jacoco report in the test phase
Error
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.2:report (default-report) on project testproject-api: An error has occurred in JaCoCo report generation.: Error while creating report: Error while analyzing d:\workspace\api\target\classes\pkg\ResponseBuilder.class. Cannot process instrumented class pkg\ResponseBuilder.class. Please supply original non-instrumented classes. -> [Help 1]
Code
Please find the code below
<profiles>
<profile>
<id>code-coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<version>${jacocoVersion}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacocoVersion}</version>
<executions>
<!-- Off line instrumentation is needed to compute coverage for Power Mock tests -->
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${maven.surefire.plugin.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- Workaround to https://code.google.com/p/powermock/issues/detail?id=504 -->
<argLine>-XX:-UseSplitVerifier</argLine>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
</profile>
The issue has been resolved now. I need to add test phase for default-restore-instrumented-classes goal. Please find the updated code
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${maven.surefire.plugin.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- Workaround to https://code.google.com/p/powermock/issues/detail?id=504 -->
<argLine>-XX:-UseSplitVerifier</argLine>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacocoVersion}</version>
<executions>
<execution>
<id>coverage-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<phase>test</phase>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>coverage-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Related
I am working on documentation using the Maven Javadoc plugin, including a delombok phase to document getters and setters, then push to gh-pages. However, this pulls in other lombok generated methods such as equals. Is there a way to specify only a subset of methods to be documented after delomboking?
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.12.2</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.0.0-beta4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.10.0</version>
<executions>
<execution>
<id>delombok</id>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<encoding>UTF-8</encoding>
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<bottom>Copyright © {currentYear}. All rights reserved.</bottom>
<show>public</show>
<sourcepath>module-a/target/delombok;
module-b/target/delombok;</sourcepath>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<checkoutDirectory>${project.build.directory}/scmpublish</checkoutDirectory>
<checkinComment>Publishing javadoc for ${project.artifactId}:${project.version}</checkinComment>
<content>${project.javadoc.directory}</content>
<skipDeletedFiles>true</skipDeletedFiles>
<pubScmUrl>scm:git:git#github.com:MyNamespace/MyProject.git</pubScmUrl>
<scmBranch>gh-pages</scmBranch>
</configuration>
</plugin>
</plugins>
I have created a soapui test cases for testing rest webservice. All the steps are executing fine from SoapUI. But when i integrate it with maven and do build, not all steps are executing.
I am using groovy script to assert response.
Also using property transfers
Maven plugin config is like below:
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-pro-maven-plugin</artifactId>
<version>4.6.1</version>
<executions>
<execution>
<id>QClearanceTest</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<projectFile>soapui/soapui-project.xml</projectFile>
<outputFolder>${project.build.directory}/surefire-reports</outputFolder>
<junitReport>true</junitReport>
<printReport>true</printReport>
<projectProperties>
<projectProperty>NameInsured=Company</projectProperty>
</projectProperties>
<settingsFile>soapui\soapui-settings.xml</settingsFile>
</configuration>
</plugin>
Thanks in advance.
It worked after upgrading the plugin and adding a dependency:
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.5.0</version>
<executions>
<execution>
<id>QClearanceTest</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<projectFile>soapui/soapui-project.xml</projectFile>
<outputFolder>${project.build.directory}/surefire-reports</outputFolder>
<junitReport>true</junitReport>
<printReport>true</printReport>
<projectProperties>
<projectProperty>NameInsured=Company</projectProperty>
</projectProperties>
<settingsFile>soapui\soapui-settings.xml</settingsFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.jgoodies</groupId>
<artifactId>forms</artifactId>
<version>1.0.7</version>
</dependency>
</dependencies>
</plugin>
soapui-settings.xml
<con:soapui-settings xmlns:con="http://eviware.com/soapui/config">
<con:setting id="HttpSettings#socket_timeout">200000</con:setting>
</con:soapui-settings>
If I define toolchain plugin in activated by default profile it's not working for some plugin such as maven-javadoc-plugin(for maven-compiler-plugin it is working) :
<profile>
<id>jdk-toolchain</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${project.javaVersion}</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
</build>
</profile>
In other case it work perfect for all plugin:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${project.javaVersion}</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
...
</plugins>
</build>
Why is this happening?
you have to bind the execution of your plugin into validate phase:
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
I'm trying to create separate profiles which using flyway-maven-plugin, but phase definition doesn't work properly. Which mean that when i use both profiles i have an error on execution because i guess "drop-create-database" using configuration from "migrate-database" thus it`s failed. Does anyone have an idea how to fix it?
<profiles>
<profile>
<id>drop-create</id>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.1</version>
<configuration>
<driver>net.sourceforge.jtds.jdbc.Driver</driver>
<table>MIGRATION_LOG</table>
<sqlMigrationPrefix>EMP_</sqlMigrationPrefix>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>drop-create-database</id>
<!-- Need to garantee order of execution -->
<phase>package</phase>
<goals>
<goal>clean</goal>
<goal>migrate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>migrate</id>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.1</version>
<configuration>
<driver>net.sourceforge.jtds.jdbc.Driver</driver>
<table>MIGRATION_LOG</table>
<sqlMigrationPrefix>ALL_</sqlMigrationPrefix>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>migrate-database</id>
<phase>pre-integration-test</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
You have to specify the configuration per execution instead of per plugin. Otherwise a later configuration for the same plugin will overwrite previous ones.
This means your pom.xml should look something like this:
<profiles>
<profile>
<id>drop-create</id>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>drop-create-database</id>
<!-- Need to garantee order of execution -->
<phase>package</phase>
<goals>
<goal>clean</goal>
<goal>migrate</goal>
</goals>
<configuration>
<driver>net.sourceforge.jtds.jdbc.Driver</driver>
<table>MIGRATION_LOG</table>
<sqlMigrationPrefix>EMP_</sqlMigrationPrefix>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>migrate</id>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>migrate-database</id>
<phase>pre-integration-test</phase>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<driver>net.sourceforge.jtds.jdbc.Driver</driver>
<table>MIGRATION_LOG</table>
<sqlMigrationPrefix>ALL_</sqlMigrationPrefix>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
I need to include more than one WSDL in my Maven JAXWS configuration and I need to specify different output directories for them since some of the method names in wsdlA conflict with method names in wsdlB. I'm using org.jvnet.jax-ws-commons and I need bindings to apply only to wsdlA, not wsdlB.
This is what I have at the moment:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Configure Output -->
<packageName>com.mycee.project.model</packageName>
<sourceDestDir>src/main/java</sourceDestDir>
<!-- Configure WSDL Location -->
<wsdlFiles>
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdla.wsdl
</wsdlFile>
<!--
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdlb.wsdl
</wsdlFile>
-->
</wsdlFiles>
<!-- Configure Binding Location -->
<bindingDirectory>
${basedir}/src/jaxws/binding
</bindingDirectory>
<!-- Make Output Verbose -->
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
UPDATED:
<build>
<pluginManagement>
<plugins>
<!-- WSDL GENERATOR PLUGIN -->
<!-- mvn jaxws:wsimport -->
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- WSDL A -->
<execution>
<id>WSDLA</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model.wsdla</packageName> <staleFile>${project.build.directory}/jaxws/stale/wsdl.a.done</staleFile>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdla.wsdl</wsdlFile>
</wsdlFiles>
<bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory>
</configuration>
</execution>
<!-- WSDL B -->
<execution>
<id>WSDLB</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model.wsdlb</packageName>
<staleFile>${project.build.directory}/jaxws/stale/wsdl.b.done</staleFile>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdlb.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
<!-- Common Config -->
<configuration>
<verbose>true</verbose>
<wsdlDirectory>
${basedir}/src/jaxws/wsdl
</wsdlDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
When running mvn clean jaxws:wsimport, I get the following notification with no java code being generated:
[INFO] --- jaxws-maven-plugin:2.2:wsimport (default-cli) #
[INFO] No WSDLs are found to process, Specify
atleast one of the following parameters: wsdlFiles, wsdlDirectory or wsdlUrls.
The first thing is not to configure the configuration within the pluginManagement block. In this case it's better to define the version of the plugin only in the pluginManagement block. Furthermore to fulfill your requirement you need to have two executions like this:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<id>wsdla-exec</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model</packageName>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdla.wsdl</wsdlFile>
</wsdlFiles>
<bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory>
<verbose>true</verbose>
</configuration>
</execution>
<execution>
<id>wsdlb-exec</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model</packageName>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdlb.wsdl</wsdlFile>
</wsdlFiles>
<bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
have an execution element for each wsdl and put the configuration within it. You can keep common configuration elements outside the execution element. e.g.:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>wsdla</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdla.wsdl
</wsdlFile>
<sourceDestDir>target/gen/wsdla</sourceDestDir>
</configuration>
</execution>
<execution>
<id>wsdlb</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdlb.wsdl
</wsdlFile>
<sourceDestDir>target/gen/wsdlb</sourceDestDir>
</configuration>
</execution>
</executions>
<configuration>
<!-- Configure Output -->
<packageName>com.mycee.project.model</packageName>
<!-- Configure Binding Location -->
<bindingDirectory>
${basedir}/src/jaxws/binding
</bindingDirectory>
<!-- Make Output Verbose -->
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Also, don't put generated code in /main/src/java as it won't get cleaned.