Skip to main content

Understanding Custom Virtual Users

When you create a new custom virtual user (VU) type, two source files are created. The first source file defines a class that extends the base VU class. So, for example, if you create a new VU type called MyJavaVU, based on the standard Java VU, then a source file called MyJavaVU.java will be created, containing the following code:

public class MyJavaVU extends com.facilita.fc.runtime.VirtualUser
{
@Override
public void pre() throws Exception
{
//do not remove following line
super.pre();

// Put any code that needs to execute at the start of the test here
}

@Override
public void post() throws Exception
{
// Put any code that needs to execute at the end of the test here

//do not remove following line
super.post();
}

...
}

The second source file defines a class that extends the base virtual user script class. So, in the example above, a source file called MyJavaVUScript.java will be created containing the following code:

public abstract class MyJavaVUScript extends com.facilita.fc.runtime.VirtualUserScript
{
@Override
public void pre() throws Exception
{
//do not remove following line
super.pre();

// Put any code that needs to execute at the start of the test here
}

@Override
public MyJavaVU getVU()
{
return (MyJavaVU)super.getVU();
}
}

You should add any code for carrying out common tasks to these two classes. Doing this will simplify your scripts and reduce duplication of code.