How to configure Extent report for temyers/Cucumber-JVM-Parallel plugin - extentreports

How to configure Extent report for temyers/Cucumber-JVM-Parallel plugin?
We are using Teamyers Cucumber-JVM-Parallel-plugin to run Selenium cucumber tests in parallel using Maven-surefire-plugin.
Using Cucumber-JVM-Parallel-plugin, we bypass need of traditional Cucumber-runner class & its multiple instances are being generated on run-time by this plugin
For each parallel run, it generates separate cucumber-report.
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<!-- Mandatory -->
<!-- List of package names to scan for glue code. -->
<glue>
<package>com.example</package>
<package>com.example.other</package>
</glue>
<!-- These are optional, with the default values -->
<!-- Where to output the generated tests -->
<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/test/resources/features/</featuresDirectory>
<!-- Directory where the cucumber report files shall be written -->
<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 -->
<plugins>
<plugin>
<name>json</name>
</plugin>
<plugin>
<name>com.example.CustomHtmlFormatter</name>
<extension>html</extension>
</plugin>
</plugins>
<!-- 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>#billing</tag>
<tag>~#billing</tag>
<tag>#important</tag>
<tag>#important,#billing</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', 'feature-title', 'pattern'] -->
<namingScheme>simple</namingScheme>
<!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
<namingPattern>Parallel{c}IT</namingPattern>
<!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
<parallelScheme>SCENARIO</parallelScheme>
<!-- 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>com.example</packageName>
</configuration>
</execution>
</executions>
</plugin>
How to configure Extent report for it.
Thanks

Since version 4.0.0 cucumber supports parallel execution. You can use that and use Extent as you would for a normal execution.

Related

Alfresco, embed a binary inside the amp

I have an alfresco community amp module, which also need a client msi to be installed on the client PC.
To solve the distribution problem I tought about embedding the installer inside the amp to give the user the possibility to download it and install it when needed.
It is a correct approach? and which is the best correct to put the biniry file in?
The file should be downloaded from a link inside alfresco share, displayed when the user permorm some actions on a document
I have resolved my problem with maven-resoures-plugin configured as followed. Maybe this is not the best options, but it worked.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>msi</nonFilteredFileExtension>
</nonFilteredFileExtensions>
<resources>
<resource>
<directory>/src/main/myLib</directory>
<filtering>false</filtering>
</resource>
</resources>
<outputDirectory>${basedir}/target/amp/web/myShare/js/myLib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

Project files created with the maven-eclipse-plugin are not supported in M2Eclipse

We have a really simple Tycho project:
<properties>
<tycho-version>0.26.0</tycho-version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.build.timestamp.format>yyyyMMdd_HHmmss</maven.build.timestamp.format>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<extensions>true</extensions>
<version>${tycho-version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<!-- snipped because probably not relevant -->
</plugin>
</plugins>
</build>
When we execute the maven goal eclipse:eclipse, we get the following weird comment in the .project files of features and products:
NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.
(A nonsense exception, because we execute it on the command line, there is no M2Eclipse involved at all.)
We could probably live with that, but the .classpath files look like that:
<classpathentry kind="lib" path="C:/Users/WileCoyote/.m2/repository/p2/osgi/bundle/com.itextpdf/5.5.3/com.itextpdf-5.5.3.jar"/>
<classpathentry kind="lib" path="C:/Users/WileCoyote/.m2/repository/p2/osgi/bundle/org.acme.config/2.0.2.v201506191015/org.acme.config-2.0.2.v201506191015.jar"/>
<!-- etc. -->
And so if imported in another user's workspace, these projects don't work anymore.
Here is an explanation on how to fix the problem, but that's really a no-brainer (remove the broken class path entries from the class path, because features and products don't need them anyway).
What I really want to know is why it happens at all? What is the problem? How do I fix it?

What are the steps to creating a custom Service Mix distribution

ServiceMix's documentation on creating a custom distribution merely states the steps to creating a custom karaf distribution. I understand that Karaf is the backbone of ServiceMix and ServiceMix is a custom distribution of Karaf.
Has anyone actually built a custom esb on top of servicemix rather than on top of karaf? If so how did you do it?
How did you stage the project with servicemix's src?
Here are some steps that I wish I had when trying to figure this out...
Download the sources for the version of service mix you want to build on: https://github.com/apache/servicemix/releases
Unpack the sources zip into any folder.
Create a project with the following layout:
MyESB
pom.xml
src
main
java
Copy the contents from the pom.xml located in apache-service-mix-x.x.x-src/assembly to your pom.xml
In that pom.xml, replace the artifactId, and name to look something like this:
<parent>
<groupId>org.apache.servicemix</groupId>
<artifactId>parent</artifactId>
<version>5.4.0</version>
</parent>
<groupId>com.mycompany.esb</groupId>
<artifactId>mycustom-esb</artifactId>
<packaging>pom</packaging>
<name>Custom :: ESB</name>
Copy the resource directories of apache-service-mix-x.x.x-src/assembly/src/main to MyESB/src/main.
Make whatever customizations you want to the org.apache.karaf.tooling:features-maven-plugin or the configuratoin files in the resource directories you just copied over.
For example, If you wanted to add a particular feature you could do the following edits to your pom.xml:
Add a features.xml to add-features-to-repo configuration descriptors
Add myfeature to the add-features-to-repo features list
To have that feature started by default, add the feature to the featuresBoot property located here: MyESB\src\main\filtered-resources\etc\org.apache.karaf.features.cfg
Run the maven install target! This will build a zip file into the MyESB/target folder. Now you can unplack that and run servicemix.bat
After starting your ESB, verify that your feature is installed by entering the following command into the Karaf console:
features:list | grep myfeature
Well, just do it like servicemix itself it does. And tbh it's just the way it's described in the Karaf documentation.
For an example you might want to look here
In short define it in your custom assembly POM, take a look at the following snippet:
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<executions>
<execution>
<id>add-features-to-repo</id>
<phase>compile</phase>
<goals>
<goal>features-add-to-repository</goal>
</goals>
<configuration>
<descriptors>
<descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.activemq/activemq-karaf/${activemq.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.camel.karaf/apache-camel/${camel.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.cxf.karaf/apache-cxf/${cxf.version}/xml/features</descriptor>
<descriptor>file:${basedir}/target/classes/internal.xml</descriptor>
<descriptor>file:${basedir}/target/classes/features.xml</descriptor>
<descriptor>file:${basedir}/target/classes/examples.xml</descriptor>
</descriptors>
<features>
<feature>cxf</feature>
<feature>obr</feature>
<feature>config</feature>
<feature>standard</feature>
<feature>package</feature>
<feature>kar</feature>
<feature>ssh</feature>
<feature>management</feature>
<feature>eventadmin</feature>
<feature>activemq-broker-noweb</feature>
<feature>activemq-service</feature>
<feature>camel</feature>
<feature>camel-cxf</feature>
<feature>activemq-camel</feature>
<feature>camel-blueprint</feature>
<feature>war</feature>
<feature>jaxrs-api</feature>
</features>
<includeMvnBasedDescriptors>true</includeMvnBasedDescriptors>
<repository>target/features-repo</repository>
</configuration>
<inherited>false</inherited>
</execution>
</executions>
</plugin>
If you need your own custom bundles/features make sure you
a) have a feature descriptor for your own bundles
b) define the feature descriptor
c) tell the plugin to use the corresponding feature

Generate feature xml with feature dependencies using maven plugin

I am using the maven-feature-plugin
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>features-maven-plugin</artifactId>
<version>2.3.6</version>
<executions>
<execution>
<id>generate</id>
<phase>generate-resources</phase>
<goals>
<goal>generate-features-xml</goal>
</goals>
<configuration>
<bundles>src/main/resources/bundle.properties</bundles>
<kernelVersion>2.3.6</kernelVersion>
<outputFile>target/features.xml</outputFile>
</configuration>
</execution>
</executions>
</plugin>
This works pretty well but one of my generated features depends on the pax-cdi feature is there a way for me to get the plugin to add this for me? For example I have some dependencies defined in the bundle.properties file that cannot be resolved automatically, could I add a feature in this file as well?
You can add the feature as a maven dependency in your pom:
<dependency>
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-features</artifactId>
<version>0.8.0</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
This will result a feature.xml containing the pax-cdi features (providing that karaf-maven-plugin is configured with <aggregateFeatures>true</aggregateFeatures>).
You can also leave it to the container to pull in the pax-cdi feature. Just edit $KARAF_HOME/etc/org.apache.karaf.features.cfg where you can enlist your pax-cdi-features by adding the maven url to the list of featuresRepositories.
featuresRepositories=....
....,\
mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features
Then add pax-cdi to the list of boot features
featuresBoot=.....,pax-cdi,...
Karaf will start the bundles of pax-cdi when it boots, so that your bundles can find those cdi packages available.
I think that the karaf convention is that the pax-cdi feature should be provided by the container itself, so you don't need to add those bundles to your feature descriptor.
To use pax-cdi feature in karaf enter the following in your Karaf shell
features:addurl mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features

How do placeholders work in Flyway?

I'm evaluating Flyway for use in my project. Our current SQL scripts contain placeholders for things like URLs which will have a different domain names depending on the environment (dev, qa, prod).
Specifically, we might have INSERT statements like
INSERT INTO FEED VALUES ('app.${env.token}.company.org/feed1', 'My Feed');
${env.token} needs to be replaced with 'dev', 'qa', or 'prod'.
We have about 50 different properties that could potentially need replacement in SQL scripts. The properties all reside in one or two properties files.
Is there a way to run the Flyway Ant migration task so that it pulls the replacement tokens and values from a properties file? Something along the lines of the Ant filter task?
Currently when supplying placeholders as properties, the property name should be prefixed with flyway.placeholders.
For example the ${env.token} placeholder can be specified directly as this Ant property: flyway.placeholders.env.token
There is currently no support for passing a property file directly, without using prefixes for the property names. Feel free to raise an issue in the Issue Tracker. :-)
If the token was subdomain:
INSERT INTO FEED VALUES ('app.${subdomain}.company.org/feed1', 'My Feed');
The values in flyway.conf:
flyway.url=jdbc:mydb://db
flyway.user=root
flyway.schemas=schema1
flyway.placeholders.subdomain=example
Or command line:
flyway -url=jdbc:mydb://db -user=root -schemas=schema1 -placeholders.subdomain=example migrate
Would run the script as:
INSERT INTO FEED VALUES ('app.example.company.org/feed1', 'My Feed');
From my experience, it's much easier to use environment variables
instead of CLI or config file (especialy when using docker and k8s).
You can use environment variables in the following format -
export FLYWAY_PLACEHOLDERS_USER=${USER}
Then in you sql statement, use this variable like this -
INSERT INTO tmptable (user)
VALUES ('${user}')
read more about environment variables here
Maven version:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<configuration>
<url>jdbc:mysql://localhost/cloud</url>
<user>root</user>
<password>root</password>
<placeholderReplacement>false</placeholderReplacement>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Resources