3

I build a test plan on Jmeter and running that from maven. But I don't know how to take those user defined variables from the command line when I am running the test on maven that I have specified in Jmeter. For example I have defined the number of threads field in jmeter with "${__P(users)}", or I have some if controller condition to run the specific thread. And specified the if condition of if controller with "${__P(tiff)}" == "true".

So

  • how do I take the values of tiff or users from command line when I am running the test with maven. What should I include in my POM.xml file?
  • how should I write the command line statement to achieve this goal

My dependencies and plugins in pom.xml are as follows:

<dependencies>
    <dependency>
      <groupId>org.jvnet.hudson.plugins</groupId>
      <artifactId>jmeter</artifactId>
      <version>0.3.0</version>
      <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>1.9.1</version>
            <executions>
                <execution>
                    <id>jmeter-tests</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
MAK
  • 101
  • 3
  • 10

1 Answers1

5

First add this block after description tag

 <properties>
     <test.users>30</test.users>
      <test.tiff>true</test.tiff>
  </properties>

Add after executions tag this block:

            <configuration>                       
                <propertiesUser> 
                    <users>${test.users}</users>
                    <tiff>${test.tiff}</tiff>
                </propertiesUser> 
            </configuration> 

Then run;

 mvn -Dtest.users=50 -Dtest.tiff=true verify
UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • But what if I want to take the values of these variables from command line when running maven? – MAK Aug 13 '14 at 07:01
  • Where should I add the properties tag? like in the build tag or in the plugins tag? – MAK Aug 13 '14 at 07:23
  • Near the top of pom file before those tags, make a quick google on pom to see, it's after artifactId – UBIK LOAD PACK Aug 13 '14 at 07:40
  • I think it is running for 30 threads that is specified in the properties tag. Not for what i specified in the command line i.e 2. I give the value of -Dusers=2. But i think it was running for 30 threads. – MAK Aug 13 '14 at 07:50
  • It's definitely running with the value specified here. " 30 true " not for the value given in the command line by this statement: mvn -Dusers=50 -Dtiff=true verify – MAK Aug 13 '14 at 07:51