I would like to integrate blazemeter random CSV data plugin set into my jmeter maven project. I am new to both maven and jmeter 3.2, but I have got a project built.
However there is no information on how I can setup the random CSV data plugin and how it should be setup in the configuration of the POM file.
So far, I have added the dependencies for the plugin, but there is no documentation on configuration within the pom file.
Dependency:
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-cmn-jmeter</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_components</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-emulators</artifactId>
<version>0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.blazemeter</groupId>
<artifactId>jmeter-plugins-random-csv-data-set</artifactId>
<version>0.6</version>
</dependency>
Is there a way I can configure the plugin in the verify stage or do I configure the plugin by adding in the properties.user and set the values within the in the pom file.
This is not how you should use dependencies in your JMeter Maven project, you should add any required JMeter Plugins into configuration/jmeterExtensions section like:
<configuration>
<jmeterExtensions>
<artifact>com.blazemeter:jmeter-plugins-random-csv-data-set:0.6</artifact>
<artifact>kg.apc:jmeter-plugins-emulators:0.4</artifact>
<artifact>kg.apc:jmeter-plugins-cmn-jmeter:0.5</artifact>
</jmeterExtensions>
<downloadExtensionDependencies>false</downloadExtensionDependencies>
</configuration>
Full pom.xml just in case:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>mvn-jmeter</artifactId>
<version>1.0-SNAPSHOT</version>
<name>maven-jmeter-demo</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<jmeterExtensions>
<artifact>com.blazemeter:jmeter-plugins-random-csv-data-set:0.6</artifact>
<artifact>kg.apc:jmeter-plugins-emulators:0.4</artifact>
<artifact>kg.apc:jmeter-plugins-cmn-jmeter:0.5</artifact>
</jmeterExtensions>
<downloadExtensionDependencies>false</downloadExtensionDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
More information:
Adding jar's to the /lib/ext directory
Five Ways To Launch a JMeter Test without Using the JMeter GUI
Related
I want to run JUnit tests for the performance testing using JMeter Maven Plugin.
During the JUnit tests run, I use one external properties file located inside <project>/src/resources/env.properties
This file has some configuration which I need to run the tests successfully.
I have given this file in src/test/jmeter location as well but the plugin is not picking up this file.
During performance tests run using JMeter Maven Plugin, This file is not found because of the relative path given inside JUnit tests as
String fileName = "src/resources/env.properties";
I get the below error during the JMeter test run
[INFO] fileName = env.properties
[INFO] java.io.FileNotFoundException: src/resources/env.properties (No such file or directory)
Can you please help, where to give the location of this file? do I need to give in pom.xml?
These tests working perfectly fine using the JMeter application where I put this file under <JMeterApp>/bin/src/resources and run the test.
Please find below pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>myProject</artifactId>
<version>1.0-SNAPSHOT</version>
<name>MyProject</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<!-- Generate JMeter configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
<configuration>
<generateReports>true</generateReports>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins:pom:1.4.0</artifact>
<artifact>kg.apc:jmeter-plugins-json:2.7</artifact>
</jmeterExtensions>
<junitLibraries>
<artifact>com:myProject:1.0-SNAPSHOT</artifact>
</junitLibraries>
<propertiesFilesDirectory>src/test/jmeter/src/resources</propertiesFilesDirectory>
<downloadExtensionDependencies>false</downloadExtensionDependencies>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
When you run your tests via JMeter Maven Plugin the current working directory looks like:
your_project\target\some-guid-like-structure\jmeter\bin
so in order to access the file which lives under your_project\src\resources you need to refer it like:
String fileName = "../../../../src/resources/env.properties";
More information: How to Use the JMeter Maven Plugin
As per groovy-maven-plugin documentation it is possible to specify a particular groovy version to be used in a maven build. This succeeds with groovy-all versions up to 2.4.9, but version 2.5.0 or higher will break the build with the followin message, when I call "mvn validate":
[ERROR] Failed to execute goal org.codehaus.gmaven:groovy-maven-plugin:2.1.1:execute (default) on project groovy3demo: Execution default of goal org.codehaus.gmaven:groovy-maven-plugin:2.1.1:execute failed: Plugin org.codehaus.gmaven:groovy-maven-plugin:2.1.1 or one of its dependencies could not be resolved: Could not find artifact org.codehaus.groovy:groovy-all:jar:3.0.6 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
The reason is that there is no 'groovy-all-3.0.6.jar' here in mavencentral repo. Apparently the 'groovy-all-<version>.jar is no longer deployed since version 2.5.0-beta3, only sources and javadoc. Version 2.4.9 seems to be the latest version that succeeds.
So my question is: How can I use groovy 3.x in my maven build?
Thank you for any hint.
Here is my pom.xml and (besides a maven installation) you don't need more than that to reproduce the problem:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.zaphodbeeblebrox</groupId>
<artifactId>groovy3demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.6</version> <!-- 2.4.9 is the latest successful version -->
</dependency>
</dependencies>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
println '*** Generated Version Numbers and Timestamps ***'
println ' [...]'
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Due to the changes introduced with groovy v2.5 and described with Release notes for Groovy 2.5 and GROOVY-8750, you should now use either the base groovy package or the wanted groovy modules, like:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>3.0.6</version>
</dependency>
</dependencies>
...
</plugin>
To work with all groovy modules you can also use groovy-all dependency
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.7</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
I have selected Apache Commons IO, JSerialComm and Ini4J libraries via Maven repository.
But when I try to create an image via mvn javafx:jlink I get this errors:
[INFO] --- javafx-maven-plugin:0.0.2:jlink (default-cli) # JUSBPlotter ---
[WARNING] Required filename-based automodules detected. Please don't publish this project to a public artifact repository!
Error: automatic module cannot be used with jlink: ini4j from file:///root/.m2/repository/org/ini4j/ini4j/0.5.4/ini4j-0.5.4.jar
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:447)
I seems it have something to do with this:
Error: automatic module cannot be used with jlink:
My module file looks like this:
module org.openjfx.JUSBPlotter {
requires javafx.controls;
requires javafx.fxml;
requires com.fazecast.jSerialComm;
requires ini4j;
requires org.apache.commons.io;
opens org.openjfx.JUSBPlotter to javafx.fxml;
exports org.openjfx.JUSBPlotter;
}
And my pom.xml looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openjfx</groupId>
<artifactId>JUSBPlotter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.2</version>
<configuration>
<stripDebug>true</stripDebug>
<compress>2</compress>
<noHeaderFiles>true</noHeaderFiles>
<noManPages>true</noManPages>
<launcher>JUSBPlotter</launcher>
<jlinkImageName>JUSBPlotter</jlinkImageName>
<jlinkZipName>JUSBPlotterZip</jlinkZipName>
<mainClass>org.openjfx.JUSBPlotter.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
So can it be that Apache Commons IO, JSerialComm and Ini4J is to old for Maven and Jlink?
How should I solve this problem?
I'm using Eclipse IDE with OpenJDK 11.
The jlink requires all dependencies to be modular. After generation, it generates a custom JRE image including the required modules. The ini4j seems non-modular.
For non-modular dependencies, you can go with the old Classpath approach after getting the custom JRE which has been generated without non-modular ones.
Briefly, run jlink excluding the non-modulars than add the jar files of non-modulars to the generated JRE image. The modules method and Classpath method can be combined this way.
A bit of fiddling with maven plugins should do this automatically.
Example for ini4j
Define some properties for convenience.
pom.xml
<properties>
<jlink-image-name>JUSBPlotter</jlink-image-name>
<ini4j-jar-name>ini4j.jar</ini4j-jar-name>
</properties>
Disable ini4j from module-info.java (It should be enable during development, only do this when you want to package the project)
module org.openjfx.JUSBPlotter {
requires javafx.controls;
requires javafx.fxml;
requires com.fazecast.jSerialComm;
//requires ini4j;
requires org.apache.commons.io;
opens org.openjfx.JUSBPlotter to javafx.fxml;
exports org.openjfx.JUSBPlotter;
}
Configure maven-dependency-plugin to copy the jar file of ini4j into the lib/ folder in jlink image.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<!-- Copy ini4j jar into the jlink image -->
<artifactItem>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
<type>jar</type>
<destFileName>${ini4j-jar-name}</destFileName>
</artifactItem>
</artifactItems>
<!-- Set output directory to lib folder in jlink image -->
<outputDirectory>${project.build.directory}/${jlink-image-name}/lib</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</plugin>
Configure jlink launcher option in the javafx-maven-plugin in order to add the jar file of non-modular ini4j to the Classpath.
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<stripDebug>true</stripDebug>
<compress>2</compress>
<noHeaderFiles>true</noHeaderFiles>
<noManPages>true</noManPages>
<launcher>JUSBPlotter</launcher>
<jlinkImageName>JUSBPlotter</jlinkImageName>
<mainClass>org.openjfx.JUSBPlotter.Main</mainClass>
<!-- ini4j jar file will be copied to the {image-folder}/lib/ folder. The launcher script should have this option to add it to the classpath -->
<options>-cp ../lib/${init4j-jar-name}</options>
</configuration>
</plugin>
Run:
mvn clean javafx:jlink
mvn package
cd target/JUSBPlotter/bin
./JUSBPlotter
maven-dependeny-plugin will copy the jar file when you run mvn package. But the jlink image must be already generated. So run the mvn javafx:jlink first. Then run mvn package.
Refer here to see how I applied for sqlite-jdbc in my project.
I have gone through many posts and blogs but couldn't generate reportng or testng-xslt reports via maven. Finally I have got this tutorial but no luck. I cant understand what am I missing.
Here's what I have tried : It successfully generates the surefire reports in the target folder but does"nt create(generate reports) a directory for reportng reports.Following is my Pom.xml file.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tiger</groupId>
<artifactId>SampleProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SampleProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<!-- TestNG-xslt related configuration. -->
<plugin>
<groupId>org.reportyng</groupId>
<artifactId>reporty-ng</artifactId>
<version>1.2</version>
<configuration>
<!-- Output directory for the testng xslt report -->
<outputDir>/target/testng-xslt-report</outputDir>
<sortTestCaseLinks>true</sortTestCaseLinks>
<testDetailsFilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testDetailsFilter>
<showRuntimeTotals>true</showRuntimeTotals>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Looks like they have removed reporty-ng plugin from maven repository, so you may not be able to generate xslt report directly through maven.
If you want to generate XSLT reports you can take help of Ant XSLT
If you don't like the default report for any reasons, you can write your own one by implementing IReporter:
http://testng.org/doc/documentation-main.html#logging
I believe you are using below
<pluginRepositories>
<pluginRepository>
<id>reporty-ng</id>
<url>https://github.com/cosminaru/reporty- ng/raw/master/dist/maven</url>
Url is not working. They have removed it from that URL. However, I think you can use this URL https://github.com/prashanth-sams/testng-xslt-1.1.2/tree/master/src/main/java/org/testng/xslt/mavenplugin . I haven't tried it though.
You can download it from. https://drive.google.com/drive/folders/0B5v_nInLNoquV1p5YWtHc3lkUkU
I have a project that uses some legacy script for processing the source code. I cannot get rid of it, so I want to call it from maven.
the problem is that I need to pass as an argument the location of a jar file. I have listed this jar file as a dependency in my pom.xml. is there a way that I can pass the absolute location of the jar file to this script?
This isn't by any means ideal, but you could call your script from maven, and pass this in as a parameter:
${settings.localRepository}/<path to artifact>
where path to artifact is a path made up of the group id and artifact id you want. Example, if you wanted a reference to the maven-jar-plugin version 2.2, you'd use this:
${settings.localRepository}/org/apache/maven/plugins/maven-jar-plugin/2.2/maven-jar-plugin-2.2.jar
I like Pascal Thivent's answer to a similar question better. You can refer to dependencies with the ${maven.dependency.junit.junit.jar.path} notation. Pascal includes a sample pom in his answer:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow</groupId>
<artifactId>q2359872</artifactId>
<version>1.0-SNAPSHOT</version>
<name>q2359872</name>
<properties>
<my.lib>${maven.dependency.junit.junit.jar.path}</my.lib>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<echo>${my.lib}</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>