Cumstom MScript Functions

MScript Implementation provides a way to call your java class functions from MScript.

To create a set of MScript functions, follow the two steps below:

  • create a java class with a constructor that accepts one parameter of type MbtScriptExecutor. Any public methods in this java class can then be called from MScript. See MScript Impl Example.
  • copy the .class or .jar file into lib folder and restart TestOptimal server.

Now you are ready to use the methods with the following two steps:

  • register your java class in “MBT Start” trigger: <action code=“$addMScriptImpl('MyMScriptMethodClass')”/>
  • call your java class function like MScript functions by prefixing the function name with an underscore (“_”), for example: <log msg=“running my mscript function: $_myMethod_2('p1','p2','$date()')”/>

where myMethod_2 is the name of the function you have implemented in the java class. Note if you place your java class in a java package, you will need to specify the full java class path in the $addMScriptImpl().

Print/export
QR Code
QR Code how_do_i_add_a_custom_method_to_mscript (generated for current page)