Relationship between Virtual User and Virtual User Script Objects
It is important to understand the relationship between the Virtual User (VU) and Virtual User Script objects that are created during test execution.
A Virtual User object of the appropriate type is created for each VU in your test. So if your test contains 100 VUs, then 100 Virtual User objects are created. These objects are created at the start of the test.
Each Virtual User object then creates a Virtual User Script object for each script that it will run during the test (i.e., one Virtual User Script object for each script in the workflow). So each Virtual User object will own one or more Virtual User Script objects.
When we create a custom VU, we create a subclass of Virtual User and a subclass of Virtual User Script. In the figure Simplified Java Virtual User class diagram below, a Custom Virtual User has been created called MyCustomUser
with an associated MyCustomUserScript
. Within our project, we can then create a script called UserJourney1 that is a sub-class of MyCustomUserScript
.
Based on the above diagram, if you have some data that is required by multiple scripts, you can store that data in the MyCustomUser
class, and it will then be available in all scripts (see example). Any data that is required only by a single script can be stored in the MyCustomUserScript
class.