MAK
MAK

Reputation: 111

How to run take the users defined variables of Jmeter from command line when running the test through jmeter-maven plugin

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

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>

Upvotes: 3

Views: 2682

Answers (1)

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34516

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

Upvotes: 5

Related Questions