Accessing "Web Test" context variables at "Load Test" level?

Hi,

For a performance test project, I need to be able to write to the "Context" table of a web test programmatically from the load test plugin. I looked at some of the load test event handlers like,

loadTest_TestSelected(object sender, TestSelectedEventArgs e)
loadTest_TestStarting(object sender, TestStartingEventArgs e)
loadTest_TestFinished(object sender, TestFinishedEventArgs e)

and I wasn't able to access the actual web test instance itself from within any of these methods. It seems like that the web test object is not publicly exposed in any of the event args (referenced with "e").

Just to clarify more, here's a common scenario: My load test has 3 web tests in it. In the first web test, I generate a random number that needs to be used in the other two web tests. So, I need to somehow store that number (in memory or in a context table) and retrieve it in the next two web tests. I might be wrong but as far as I know, you can't write to the context table of a load test from the web test level since the web test doesn't know anything about the load test it's running in. The first alternative that came to my mind, was to generate the random number before the load test starts and write it in the context of each web test when they're about to start.

If anyone has encountered this too or has a another solution, I'd appreciate it if you can help me.

Thanks.



Answer this question

Accessing "Web Test" context variables at "Load Test" level?

  • Bhasker

    Thanks a lot. This solved my problem.
  • Phil Williams

    You are going about this the correct way. First you should generate the random number in the plugin and add it to the context of each of the webtests. The order of test execution is not guaranteed, so you may not have the test which is generating the random number execute first.

    You can access the context of a web test from the TestStarting event here is example of that.:

    void loadTest_TestStarting(object sender, TestStartingEventArgs e)
    {
    e.TestContextProperties.Add(
    "object", "RandomValue");
    }



  • Accessing "Web Test" context variables at "Load Test" level?