Set public variable inside a test listener's before test case function?

Is it possible to check for the presence of a public variable and set its value using TestCaseContext inside of a beforeTestCase function?

It is possible. The test case variables can be retrieved as a map from the TestCaseContext and it appears that the map is passed by reference. So changes to the test case variables map is reflected in executing test cases. Example:


def beforeTestCaseFunction(TestCaseContext context) {

Map variables = context.getTestCaseVariables()  

if (variables.containsKey('variableName')) {  

    variables.put('variableName', 'variableValue')