Wednesday, August 13, 2014

VS 2013 Web Load Test Most Common Mistake Using Property StringBody with Content Type Json


Every time you deal with data driven web load test in Visual studio remember to follow the correct format for content type. Otherwise one ends up looking into different areas while troubleshooting the issue related to data bind data source . Sequential, Unique and random
Load Runner Vs Visual Studio Load test :-
It can be my ignorance....please spare me if you see any discrepancies in my thought or understanding process.
It reminds how load runner used to work- I used to work with performance test team who shared their screen with me to show the progress of the load run and the failed transactions. There is a threshold limit for number for transactions that is permissible to fail above which test was used to marked as RED or failed. Now coming back to what I understand, this something not about stress test but the test related to number of users that must be loaded to run the test. We used to provide the test data for each scenario and users in excel. Once recording is done during load test this data is picked by each users and constant user load or ramp up of users( step up) applied to generate real time scenario.
UNLIKE load runner, webtest in VS records the scenario and runs for all data users at once which is kind of non realistic procedure. What I mean here is, the user data is not bind during load test but it is available as complete run in web test which makes it in complacent or absurd for real time scenario.
Its like say login functionality.. I have userid and password for say 10 users in excel. I did recording of webtest with datasource bind to this excel which picks up 10 users at one go. When I apply say load test on this webtest for say 2 users it don't picks up 2 user input data but rather runs one webtest with all 10 users in one set and then subsequent round 2 with set of 10 users input.
Visual Studio Load test
[1 webtest -10 user input data]- load test -2 users = 1 Users [1webtest 10 user input data run] +1 users[1webtest 10 user input data run] 
Load Runner
[1 webtest]- load test -10 users input data feed = 10 user runs with 10 data inputs =10 run
this is perfect and concur to real time scenario
Please correct me, if you think this is not the behavior because I spend almost a month understanding this aspect , I research lot but none of the available information talk about this nitty gritties.


Do remember to apply right format structure, even missing quotes in semantics will lead you to spend lot of time solving the datasource issue..
Sometimes webtest runs fine with hardcoded login userid and password but when we bind the data source to bodystring( it is when login is in popup JS) you need to be extra careful with format.
  1. In main content panel of WebTest1.webtest
  2. Right click WebTest1 > Add Web Service Request
    1. Right click http://localhost/ > Properties
    2. Set the url to the web service end point
      1. Set Url: http://localhost:64093/api/user
    3. Expand the url http://localhost:64093/api/user
      1. Right ClickString Body > Properties
      2. Set Content Type : application/json
      3. String Body > Click Ellipsis ...
        "UserId": "{{DataSource1.UserId#csv.UserId}}"
        (NOTE: Using {{DataSource1.UserId#csv.UserId}} will set the value from the CSV.)
  3. Click Save 
Post a Comment