Donut report (donut-maven-plugin) is not getting generated when some of the tests fails - bdd

I am using Donut report (donut-maven-plugin) for aggregating a report for parallel cucumber tests ran using cucumber-jvm-parallel-plugin from github.temyers team.
Here is my POM snippet:
<profiles>
<profile>
<id>TestSuite1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<app.config>//src//test//java//envConfig//localGridConfig.properties</app.config>
<test.tag>#android</test.tag>
<dummy.tag>#dummy</dummy.tag>
<device.name>browserstack.ios</device.name>
<!--<target.env>browserStackEnv</target.env>-->
</properties>
</profile>
<profile>
<id>TestSuite2</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<app.config>//src//test//java//envConfig//sauceLabsGridConfigAndroid.properties</app.config>
</properties>
</profile>
<profile>
<id>TestSuite3</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<app.config>//src//test//java//envConfig//sauceLabsGridConfigIOS.properties</app.config>
</properties>
</profile>
</profiles>
<build>
<!--<sourceDirectory>src</sourceDirectory>-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version>
<configuration>
<parallel>methods</parallel>
<threadCount>5</threadCount>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/Parallel*IT.class</include>
</includes>
<systemPropertyVariables>
<deviceName>${device.name}</deviceName>
<targetEnv>${target.env}</targetEnv>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>4.2.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<!--<phase>validate</phase>-->
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<!-- Mandatory -->
<!-- List of package names to scan for glue code. -->
<glue>
<package>stepDefs</package>
</glue>
<!-- These are optional, with the default values -->
<!-- Where to output the generated tests -->
<outputDirectory>${project.build.directory}/cucumber-parallel/html</outputDirectory>
<!--<outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>-->
<!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->
<featuresDirectory>src/main/resources/features/</featuresDirectory>
<!-- Directory where the cucumber report files shall be written -->
<!--<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>-->
<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
<!-- List of cucumber plugins. When none are provided the json formatter is used. For more
advanced usage see section about configuring cucumber plugins -->
<format>json,html,rerun</format>
<plugins>
<plugin>
<name>json</name>
<extension>json</extension>
<!--Optional output directory. Overrides cucumberOutputDirectory. Usefull when different
plugins create files with the same extension-->
<outputDirectory>${project.build.directory}/cucumber-parallel/json</outputDirectory>
</plugin>
<!--<plugin>-->
<!--<name>com.example.CustomHtmlFormatter</name>-->
<!--<extension>html</extension>-->
<!--</plugin>-->
<plugin>
<name>com.cucumber.listener.ExtentCucumberFormatter</name>
<extension>html</extension>
</plugin>
</plugins>
<customVmTemplate>
src/main/resources/cucumber-extents-report-runner.java.vm
</customVmTemplate>
<!-- CucumberOptions.strict property -->
<strict>true</strict>
<!-- CucumberOptions.monochrome property -->
<monochrome>true</monochrome>
<!-- The tags to run, maps to CucumberOptions.tags property. Default is no tags. -->
<tags>
<tag>
<!--${dummy.tag}-->
</tag>
</tags>
<!-- Generate TestNG runners instead of JUnit ones. -->
<useTestNG>false</useTestNG>
<!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->
<namingScheme>simple</namingScheme>
<!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
<!--<namingPattern>**/Parallel*IT.class</namingPattern>-->
<namingPattern>Parallel{c}IT</namingPattern>
<!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
<parallelScheme>SCENARIO</parallelScheme>
<!--<parallelScheme>FEATURE</parallelScheme> <!–Using Feature for accomodating Scenario Outline –>-->
<!-- Specify a custom template for the generated sources (this is a path relative to the project base directory) -->
<!--<customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>-->
<!-- Specify a custom package name for generated sources. Default is no package.-->
<packageName>
</packageName>
</configuration>
</execution>
</executions>
</plugin>
<!-- Cucumber report merger
-->
<plugin>
<groupId>report.donut</groupId>
<artifactId>donut-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<id>execution</id>
<phase>post-integration-test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<sourceDirectory>${project.build.directory}/cucumber-parallel</sourceDirectory>
<outputDirectory>${project.build.directory}/TrackMergeReport</outputDirectory>
<timestamp>${maven.build.timestamp}</timestamp>
<template>default</template>
<projectName>NativeAppsAutomation</projectName>
<!-- optional -->
<customAttributes>
<customAttribute>
<name>App Name</name>
<!--<value>${app.name}</value>-->
<value>smartphone.editor.beta</value>
</customAttribute>
<customAttribute>
<name>Device Name</name>
<!--<value>${app.name}</value>-->
<value>${device.name}</value>
</customAttribute>
<customAttribute>
<name>Target Env</name>
<value>${target.env}</value>
</customAttribute>
</customAttributes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Note:
- There's no trace/mention about attempt to generate Donut report in maven run log (when one of the tests fail):
- I use mvn clean verify or mvn clean integration-test to run the framework
Run 1: PASS
Run 2: PASS
Run 3: Can't locate an element by this strategy: Locator map:
- native content: "By.chained({By.xpath: //*[contains(#text,'rints')]})"
- html content: "By.cssSelector: div[data-id='print'] > .caption"
Tests run: 51, Failures: 0, Errors: 9, Skipped: 5
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13:49 min
[INFO] Finished at: 2018-01-05T14:54:50+01:00
[INFO] Final Memory: 27M/306M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test
(default-test) on project NativeAppsAutomation-project: There are test
failures.
[ERROR]
[ERROR] Please refer to /../target/surefire-reports
for the individual test results.
[ERROR] -> [Help 1]
Noticed that - individual plain Cucumber reports (json, Html, xml) are getting generated in the target/cucumber-parallel folder as expected for both All pass & runs with failures or all failures.
Whereas , when all tests pass then Donut aggregate report is getting generated,

Related

Append or merge default maven plugin configuration

Is it possible to not override but merge or append to default plugin configuration in Apache Maven just like it's possible with parent POM configuration elements?
I'm note sure if i understand your questions correctly:
If you like for example to change the configuration of an already defined plugin you should be aware that you need to use the correct execution id which can be looked at during a default build which is printed out in the log output (something like this):
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) # parent ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) # parent ---
[INFO]
The value in braces gives the hint: default-clean can now be used to add information to the configuration or also to change behaviour:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>default-clean</id>
<configuration>
<.. combine.children="append">
</...>
</configuration>
See more explanations following.
You can do this if you need. Lets say you have defined the following in a parent pom file:
<plugin>
<groupId>..</groupId>
<artifactId>..</artifactId>
<configuration>
<values>
<value>First</value>
</values>
</configuration>
</plugin>
In an inheriting pom file you can now write the following:
<plugin>
<groupId>..</groupId>
<artifactId>..</artifactId>
<configuration>
<values combine.children="append">
<value>Second</value>
</values>
</configuration>
</plugin>
Or if you do something different:
<plugin>
<groupId>..</groupId>
<artifactId>..</artifactId>
<configuration>
<values combine.children="override">
<value>Second</value>
</values>
</configuration>
</plugin>
or you can give explicitly what is already the default:
<plugin>
<groupId>..</groupId>
<artifactId>..</artifactId>
<configuration>
<values combine.children="merge">
<value>Second</value>
</values>
</configuration>
</plugin>
This is documented in the pom reference.

maven-dependency-plugin:unpack Error

I'm trying to extract some .exe files from a dependency jar file and put them under ${project.build.directory}/classes/.
But when I execute:
mvn clean compile dependency:unpack
I get:
Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:unpack (default-cli) on project simple: Either artifact or artifactItems is required -> [Help 1
I have verified that the dependencies are available in my local repository.
In my example pom below I've used junit as an example, but no matter which dependency I list, I get the same error.
pom.xml:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes/externaltools</outputDirectory>
<includes>**/*.txt</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
The issue is due to you cannot use mvn clean compile dependency:unpack and <executions> tags together.
In documentation Maven Depdendency Plugin at the bottom part of the page you can read:
If you intend to configure this mojo for execution on the command line using: mvn dependency:unpack you must not put the configuration inside the executions tag. Your configuration should look like this:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[ groupId ]</groupId>
<artifactId>[ artifactId ]</artifactId>
<version>[ version ]</version>
<type>[ packaging ]</type>
<classifier> [classifier - optional] </classifier>
<overWrite>[ true or false ]</overWrite>
<outputDirectory>[ output directory ]</outputDirectory>
<destFileName>[ filename ]</destFileName>
<includes>[ comma separated list of file filters ]</includes>
<excludes>[ comma separated list of file filters ]</excludes>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
I have tried removing the <execution> tags and works perfectly!

java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspApplicationContextImpl | jetty:run

I am getting
java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspApplicationContextImpl
while using jetty:run plugin on a web project.
The issue is occurring only on some machines while working on some !
Java Version Used : 7
Maven Version : 3.1
Relevant dependencies and plugins:-
Adding this dependency fixed it :-
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.0.0</version>
</dependency>
If you are running jetty on a port below 1024 on linux or osx this could be caused by the process not having permissions to bind to the port. In my case above the stack trace was the error.
Blockquote[ERROR] Failed to execute goal org.mortbay.jetty:jetty-maven-plugin:8.1.4.v20120524:run (default-cli) on project projectName: Failure: Permission denied -> [Help 1]
Blockquote
Running the command with sudo fixed the issue.
This is occurred for me because the port to be used by the Jasper is already occupied by other process. I did stopped the application running on that port and restarted the app it worked fine.
you can use this configuration in pom.xml in ide->idea
<properties>
<jdk.version>1.7</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- resource plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- compiler plugin, set JDK version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<compilerArguments>
<verbose />
<bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<!-- deploye plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<!-- war plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
<!-- jetty plugin -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<systemProperties>
<systemProperty>
<name>tomcat.port</name>
<value>8098</value>
</systemProperty>
</systemProperties>
<webApp>${basedir}/target/${project.artifactId}.war</webApp>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8088</port>
</connector>
</connectors>
<scanIntervalSeconds>5</scanIntervalSeconds>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
</configuration>
</plugin>
</plugins>
</build>

How to override Maven 3.0 parent profile properties from child pom?

How to override Maven 3.0 parent profile properties from child pom?
I want to be override profile properties from a parent pom. I've used help:effective-pom -Pjmeter and can see that the child properties are not being picked up and tried many various permutations all without success. I expect the parents properties to be overridden by the child properties.
Parent pom profile:
<profile>
<id>jmeter</id>
<properties combine.self="override">
<maven.jmeter.phase>verify</maven.jmeter.phase>
<maven.jmeter.goal>jmeter</maven.jmeter.goal>
<!-- We use the ${basedir} to avoid NullPointer errors when src/test/jmeter doesn't exist -->
<!-- when running jmeter test the default to set in the child pom is ${basedir}/src/test/jmeter -->
<maven.jmeter.testFilesDirectory>${basedir}</maven.jmeter.testFilesDirectory>
<maven.jmeter.jMeterTestFile>**/*.jmx</maven.jmeter.jMeterTestFile>
<maven.jmeter.excludeJmeterTestFile>NOT_NULL</maven.jmeter.excludeJmeterTestFile>
<maven.jmeter.testResultsTimestamp>false</maven.jmeter.testResultsTimestamp>
<maven.jmeter.server>localhost</maven.jmeter.server>
<maven.jmeter.port>8080</maven.jmeter.port>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter.version}</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>${maven.jmeter.phase}</phase>
<goals>
<goal>${maven.jmeter.goal}</goal>
</goals>
<configuration>
<testFilesDirectory>${maven.jmeter.testFilesDirectory}</testFilesDirectory>
<testFilesIncluded>
<jMeterTestFile>${maven.jmeter.jMeterTestFile}</jMeterTestFile>
</testFilesIncluded>
<testFilesExcluded>
<excludeJmeterTestFile>${maven.jmeter.excludeJmeterTestFile}</excludeJmeterTestFile>
</testFilesExcluded>
<testResultsTimestamp>${maven.jmeter.testResultsTimestamp}</testResultsTimestamp>
<propertiesUser>
<!-- server and port must be defined (and used) in the JMeter jmx file as User Defined Variables
${__P(server,localhost)}
${__P(port,80)}
See http://jmeter.apache.org/usermanual/component_reference.html#User_Defined_Variables
http://jmeter.apache.org/usermanual/test_plan.html#using_variables
http://jmeter.apache.org/usermanual/functions.html#__P
http://jmeter.apache.org/usermanual/best-practices.html#parameterising_tests
-->
<server>${maven.jmeter.server}</server>
<port>${maven.jmeter.port}</port>
</propertiesUser>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
and then in the child pom:
<profile>
<id>jmeter</id>
<activation><activeByDefault>false</activeByDefault></activation>
<properties>
<maven.jmeter.testFilesDirectory>${project.basedir}/src/test/jmeter</maven.jmeter.testFilesDirectory>
<!-- csv based JMeter tests result in one graph in Jenkins, we want a graph per test -->
<maven.jmeter.excludeJmeterTestFile>**/KRAD.jmx</maven.jmeter.excludeJmeterTestFile>
</properties>
</profile>
I'm not sure properties are overridden that way. Either way, the plugin will not run as you have it, since you only define <pluginManagement> and no straight direct <plugins> child under <build>. If you don't want your plugin to run in the parent, just define the <plugins> tags in the children where you do want this running as such:
<profile>
<id>jmeter</id>
<activation><activeByDefault>false</activeByDefault></activation>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<configuration>
<testFilesDirectory>${maven.jmeter.jMeterTestFile}</testFilesDirectory>
<!-- csv based JMeter tests result in one graph in Jenkins, we want a graph per test -->
<testFilesExcluded>
<excludeJmeterTestFile>${maven.jmeter.excludeJmeterTestFile}</excludeJmeterTestFile>
</testFilesExcluded>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Hope this helps.

How to skip test api docs in maven-javadoc-plugin?

I would like to skip generating 'testapidocs' folder in my 'target/site' folder after executing 'clean skip:skip' with following configuration.
Build Configuration:
<build>
<plugins>
.................
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.2</version>
</plugin>
</plugins>
.........
</build>
Reporting Configuration:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
</plugin>
</plugins>
</reporting>
When i ran 'clean site:site' it is creating the following folders under 'target' directory:
target/site/apidoc
target/site/testapidocs - would like to skip this one
The Selective Javadocs Reports told us as
To run the Javadocs reports selectively, you need to include only the Javadocs reports that you prefer. As said in the FAQ, the configuration depends on the <build/> tag or <reporting/> tag used.
Using <build/> Tag
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<!-- Default configuration for all reports -->
...
</configuration>
<executions>
<execution>
<goals>
<goal>javadoc</goal>
<goal>test-javadoc</goal>
</goals>
<phase>site</phase>
<configuration>
<!-- Specific configuration for the given reports -->
...
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Using <reporting/> Tag
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<!-- Default configuration for all reports -->
...
</configuration>
<reportSets>
<reportSet>
<id>default</id>
<configuration>
<!-- Specific configuration for the given reports -->
...
</configuration>
<reports>
<report>javadoc</report>
<report>test-javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>aggregate</id>
<configuration>
<!-- Specific configuration for the given reports -->
...
</configuration>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
...
</project>
I hope this may help.

Resources