When running a Service Test test in LoadRunner, how can I share data across iteration for a single vuser?

  • Questions
  • When running a Service Test test in LoadRunner, how can I share data across iteration for a single vuser?
Question ID: 104649
0
0

Practically, I need to do something like get a SAML token once, put it in a variable, and not get another one for a vuser until it is near expiration.

Marked as spam
Posted by (Questions: 36, Answers: 3)
Asked on October 16, 2012 10:13 am
10 views
Answers (1)
0
Private answer

Store data in static member variables. The static keyword is basic C# stuff, but it is good to understand it in the context of ST & LR. In ST, you can specify and set ''global'' static variables at the class level:

[Serializable()]
public class TestUserCode : TestEntities
{
public static XmlNode SAMLToken = null;
public static DateTime SAMLExpiry;

...}

These static variables are shared with all instances of TestUserCode for the current vuser. By default for an ST test in LR, class instances are not shared between vusers. This can be confirmed through viewing the log files in LoadRunner for an ST test in results/log. To write to this log from Service Test, use this approach:

if (Script.LRAppender.logTextAppend != null)
Script.LRAppender.logTextAppend(''My log message'');

This means you can do something like get a SAML token once, put it in a static variable, and not get another one for a vuser until it is near expiration. Without the static keyword, these values would be reassigned for each new class instance on the thread.

Marked as spam
Posted by (Questions: 6, Answers: 167)
Answered on October 16, 2012 10:16 am