How to create JAR from jmeter scenario (.jmx file) from local maven project?

266 Views Asked by At

I have created maven project repositories on my local machine successfully.

Also, I wrote test scenario in JMeter which works fine.

As per the documents available on internet, I kept my .jmx file in "\src\test\jmeter" directory.

My POM.xml looks like:

<?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.project</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <properties>
    <jmeter.analysis.maven.plugin.version>1.0.6</jmeter.analysis.maven.plugin.version>
    <jmeter-maven-plugin.version>3.0.0</jmeter-maven-plugin.version>
    <serverParam>localhost</serverParam>
    <portParam>8080</portParam>
    <usersParam>1</usersParam>
    <rampUpTimeParam>20</rampUpTimeParam>
    <loopCount>1</loopCount>
    <timer>1000</timer>
    <dataParam>LocalData.csv</dataParam>
    <jmeterScript>Generic.jmx</jmeterScript>
    <includecontroller.prefix>${basedir}/src/test/jmeter/fragments/</includecontroller.prefix>
    <resultsaver.prefix>${basedir}/target/</resultsaver.prefix>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>${jmeter-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>configuration</id>
            <goals>
              <goal>configure</goal>
            </goals>
          </execution>
          <execution>
            <id>test</id>
            <goals>
              <goal>jmeter</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <generateReports>true</generateReports>
          <testFilesIncluded>
            <jMeterTestFile>${jmeterScript}</jMeterTestFile>
          </testFilesIncluded>
          <ignoreResultFailures>true</ignoreResultFailures>
          <propertiesUser>
            <serverParam>${serverParam}</serverParam>
            <portParam>${portParam}</portParam>
            <usersParam>${usersParam}</usersParam>
            <rampUpTimeParam>${rampUpTimeParam}</rampUpTimeParam>
            <loopCount>${loopCount}</loopCount>
            <timer>${timer}</timer>
            <dataParam>${dataParam}</dataParam>
            <includecontroller.prefix>${includecontroller.prefix}</includecontroller.prefix>
            <resultsaver.prefix>${resultsaver.prefix}</resultsaver.prefix>
            <jmeter.save.saveservice.output_format>csv</jmeter.save.saveservice.output_format>
            <jmeter.save.saveservice.print_field_names>true</jmeter.save.saveservice.print_field_names>
            <jmeter.save.saveservice.successful>true</jmeter.save.saveservice.successful>
            <jmeter.save.saveservice.label>true</jmeter.save.saveservice.label>
            <jmeter.save.saveservice.time>true</jmeter.save.saveservice.time>
          </propertiesUser>
          <jMeterProcessJVMSettings>
            <arguments>
              <argument>-XX:MaxMetaspaceSize=256m</argument>
              <argument>-Xmx1024m</argument>
              <argument>-Xms1024m</argument>
            </arguments>
          </jMeterProcessJVMSettings>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

I have successfully run the jmx with the command "mvn verify".

What I want to do now is packaging the necessary JMX file with the necessary maven in a JAR and run the JMX test scenario from the JAR.

Any help in how to do so ?

0

There are 0 best solutions below