Skip to content

Structure of a test script#

Measmatic offers two types of tests: python script based and LUA script based. Python tests are universally applicable and do work with any type of instrument that can be controlled through remote control interface. LUA tests are very specific tests tailored to run on the Test Script Processor (TSP) of Keithley instruments.

Test plan processing#

A Measmatic project can contain various tests which are executed sequentially. Test sequences are special tests which can contain other tests as child elements. Test sequences can control if and how often child test are executed. Each test can define actions for those phases:

flowchart LR
    Init-->TestInit
    TestInit-->Execute
    Execute-->TestFinish
    TestFinish-->Finish

Init#

This function is executed once for every test or test sequence when the test plan is executed. In this function general precondition should be checked. If any check fails an error can be raised to prevent any test execution.

TestInit#

This function is called every time the test is about to get executed. For tests that are placed inside a test sequence this might happen multiple times within a test plan execution.

Execute#

This function runs the actual test. Here the main test logic should go.

TestFinish#

This function is called every time the test execution was done, no matter if test execution was successful or an error occurred. For tests that are placed inside a test sequence this function might be called multiple times within a test plan execution.

Finish#

This function is executed once after every test in the test plan was executed.

Python test script#

A python test may contain all of the above mentioned functions. Apart from Execute() defining those functions is optional. As parameter every function gets an object of type PyTestExec. This object offers the interface to Measmatic. A interface description can be found on page Measmatic python test interface.

# is executed once when the test plan execution starts 
def Init(measmatic):
    check_test_plan_execution_conditions()

# is executed every time before test execution
def TestInit(measmatic):
    check_test_()

# runs the actual test
def Execute(measmatic):
    execute()

# is executed every time after test execution
def TestFinish(measmatic):
    do_cleanup()

# is executed once when the test plan execution ends 
def Finish(measmatic):
    do_cleanup_after_test_plan_execution()

LUA test script#

A test based on a LUA script is downloaded once when a test run is started in Measmatic. The script then gets executed for every time the test runs during script execution.