Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using parameters as user Defined Variables?

Tags:

jmeter

We run our tests in non gui mode and pass in various parameters like Server, port, threads etc. We'd also like to run our test in GUI mode, and be able to change these parameters in the GUI.

What I wanted to do, was use 2x User Defined variable objects, and have one with static data we can edit, and another with parameters. That way the actual test plan doesn't change, but we can set variables as parameters, and just disable the static data one. Or disable the parameterized one when we want to run with static data.

But this doesn't seem to work - no errors nothing.

like image 388
Dominic Bou-Samra Avatar asked May 23 '11 01:05

Dominic Bou-Samra


2 Answers

I do something similar, but I used a UDF for this.

What I did was set up my variables and use default values.

VARNAME      VALUE  
otl_PROTOCOL ${__P(otl_protocol,https)}  
otl_PORT     ${__P(otl_port,443)}  
otl_THREADS  ${__P(otl_threads,1)}      
otl_REPS     ${__P(otl_reps,1)}  
otl_RAMP     ${__P(otl_ramp,0)}  

I did one for server name as well. This way, I can use the defaults here or I can pass in parameters in either the command line args or in my user.properties. This works very well for me.

like image 102
Lee Lowder Avatar answered Dec 02 '22 11:12

Lee Lowder


How are you passing in values from non-GUI mode? via CSV, using properties, User-Parameters, etc.?

If CSV, this is an easy fix. Simply create a User Defined Variables (UDV) object at the Test Plan Level and "hard code" all your parameters (Server, port, etc.). Keep your CSV config. If you run in GUI mode, disable the CSV and enable the UDV. When you save the file, keep the CSV enabled and the UDV disabled - that way when you run from non-GUI it'll read the CSV file.

If using properties, I would do the following: Create a UDV with all your parameters (Server, etc.). Before entering values, copy the component so you have TWO identical UDVs. In UDV 1, enter the property value from the command line. In UDV 2, enter the "hard coded" values. Throughout your script, replace any references to the properties with variable references. It would look something like this:

        UD1:                               UD2:
  Name        Value                  Name        Value
    SERVER      ${__P(Server)}          SERVER      devdomain.com
    PORT        ${__P(Port)}            PORT        4111


Some HTTP Request

Domain: ${SERVER}

If using user-parameters, it would be the same concept as above.

like image 29
BlackGaff Avatar answered Dec 02 '22 11:12

BlackGaff