Functional and Performance testing using Jmeter

You have probably used Jmeter on some of your previous projects, in this blog I take a dig at using Jmeter for functional and performance testing a WCS store. It is a powerful tool and supports advanced features like pre, post processing of request/response data using BSL shell script, you can use your existing java skill sets to write these processors.

We will look at how Jmeter can be used to record a specific use case in WCS store for performing functional/performance tests.

Step 1: Add HTTP Proxy Server Element for recording script, follow steps as shown in the screenshot below



Click on "Start" button to run the Proxy on port 8080


Step 2: In the previous step we have enabled Jmeter Http Proxy to run on localhost port 8080, now we need to modify the browser proxy setting to tunnel all traffic through this proxy. following screenshot is an example from FF browser


Step 3: Before we record scripts we need to set few exclusion and inclusion rules on Jmeter http proxy, the example below excludes static assets like JS, images and html pages, you can modfy this setting based on your testing needs, fow now following rules are sufficient for testing dynamic WCS Pages.

.*\.jpg
.*\.js
.*\.png
.*\.gif
.*\.swf
.*\.css



Create a new Test Plan as shown in the screen shot below, I have named this thread group as "User Login".



Step 4:  Launch your browser and browse through the site to record following steps

View Madison's Home Page
Click on Sign in link
Sign in with username/password

You should be now able to see recorded scripts under "Test Plan", as you can see in the screenshot below It has captured Dynamic URL's for my Use Case.


Step 5: WCS sets quite a few cookies which are used to identify a logged in or guest session, Jmeter supports "Http Cookie Manager" config element, this can be used to ensure cookie values are passed in every consecutive requests, add the "Http Cookie Manager" config element as follows




Make sure clear cookie setting is selected, this will ensure every new iteration of the test will clear all cookies before executing any steps in the test.


Step 6: Now that the script is recorded we would like to feed in few dynamic value from an external data feed file, for instance in this case I would like to feed in a set of test username/password which should be used by my test script, to achieve this we need to add "CSV Data Config" element as shown in the screenshot below.




Make sure you place the seed data file under the Jmeter installation folder, in the sample below I have created a folder seed_data under my Jmeter installation folder.


The seed data consists of following, the first row indicates the variable names and next set of rows indicate values in them, for every iteration of the thread Jmeter will read consecutive row of data and automatically convert them to Jmeter variable ${username} and ${password}

username,password
user1,user1password
user2,user2password
user3,user3password



Modify the recorded step .../servlet/logon and replace the username/password that was used during recording with Jmeter variables ${username} and ${password} as shown in the screen shot below

When you execute the script Jmeter will dynamically feed username/password from your external feed file to the script, this way we can perform a test which replicates multiple user logging into the site





Step 7: How do we know that we are getting expected results from the script execution? Jmeter has post-processor element which can be used to script code that can look for specific values in the response HTML page, this can be used for functional testing of pages.

When you login from browser we are displayed a welcome message in the post login page as shown in the screen shot below, we will use this text check rule in the post processor script


Add "Response Assertion" element to your test step and make sure you make selections as shown in the screenshot below, the pattern check in this case checks for Welcome, <username>



Step 8:  Start the test by clicking on start button, you should be able to see the assertion results under "View"


As you can see in the screenshot when ever login fails the post processor can not find the welcome message and hence the test step will be marked as failed.

As you can see Jmeter provides a very simple yet a powerful set of features which can be used for automation of functional test and can be used for performance testing as well, more to come in my future blogs on some of the more advanced features of Jmeter which can be used in the context of WCS testing.

For more reading read through the official documentation available on http://jmeter.apache.org/

Pituluik Media Blogger | Freelancer |Operations Manager | Marketing and Sales Manager | Lancer Evo 4 Community. Indonesian Bloggers Who Become Bloggers Because of Hobby. Feel free to connect with me on Social Media Instagram @alberandesko

0 Response to "Functional and Performance testing using Jmeter"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel