Tuesday, April 3, 2012

URL and PORT parametrize using JMeter



Scripts should be reusable means if client want to execute the script in QA environment then scripts should be run in QA environment and client want to run in SIT environment then scripts shold be run in SIT environment. For this performance tester is able to parametrize the Application URL and Port numbers.
If QA environment URL : http://staging.qa.com then just change the URL in parametrize file
If QA environment URL : http://staging.sit.com then just change the URL in parametrize file

So our script is reusable in any environment by doing parametrize.

For this we are using pre processor (User Parameter)

Step 1: Start Jmeter from jmeter.bat , In Jmeter UI should open then Add Thread group to "Test Plan"
               Test Plan--> Thread Group


Step 2: Add HTTP Request to Thread Group
              Thread Group--> Sampler--> Http Request
  Step 3: Add URL and Port to "HTTP Request"
                 Here URL : www.google.com
                           Port: 80


Then Start Parameterizing URL and PORT, see how to parameterize below 
Step 4:Add user parameter to the test plan 
                        Test Plan-->Pre processors--> User Parameters

Add two variables 'url' and 'port' to user parameters pre processor, shown below
Note: Add this just above to "Thread Group"

Step 5: Add 'url' and 'port' variables to the HTTP request samplers. Shown below

Step6: Verify whether these values are going or not from "View Results Tree"

No comments: