Forum Discussion
GMSoapUI
12 years agoContributor
I can see your example working but where yours differs from mine is that I am using setPropertyValue to set the value at runtime in another Groovy script like this:
In my listener I am then using:
In the other two listeners (TestRunListener.afterStep and TestSuiteRunListener.beforeTestCase) this works perfectly and writes MESSAGE: Hello world! to the log. This does not work in the TestSuiteRunListner.afterRun listener. It doesn't matter whether I use long-hand or short-hand notation - I get the same error everytime.
If I comment the def vntProject = testRunner.testCase.testSuite.project; the error is no longer present.
I think this must be to do with context or scope because the event listener is TestSuiteRunListner.afterRun then I think that there is no context for testRunner / testCase / testSuite. I really need to resolve this so if this could be investigated to determine if this is a defect that would be great.
def vntProject = testRunner.testCase.testSuite.project;
...
vntProject.setPropertyValue( "myProjectLevelVariable", "Hello world!" );
In my listener I am then using:
...
log.info( "MESSAGE: " + vntProject.getPropertyValue( "myProjectLevelVariable" ) );
...
In the other two listeners (TestRunListener.afterStep and TestSuiteRunListener.beforeTestCase) this works perfectly and writes MESSAGE: Hello world! to the log. This does not work in the TestSuiteRunListner.afterRun listener. It doesn't matter whether I use long-hand or short-hand notation - I get the same error everytime.
ERROR:groovy.lang.MissingPropertyException: No such property: testCase for class
If I comment the def vntProject = testRunner.testCase.testSuite.project; the error is no longer present.
I think this must be to do with context or scope because the event listener is TestSuiteRunListner.afterRun then I think that there is no context for testRunner / testCase / testSuite. I really need to resolve this so if this could be investigated to determine if this is a defect that would be great.