cancel
Showing results for 
Search instead for 
Did you mean: 

Caused by: groovy.lang.MissingPropertyException: No such property: testCase for class: Script2

SOLVED
Occasional Contributor

Caused by: groovy.lang.MissingPropertyException: No such property: testCase for class: Script2

I'm using below script to get the error message from test-step in listener level. I place this script under TestRunListener.afterRun

 

def logPrefix = testCase.getName() + ': '
log.info (logPrefix + 'Number of results = ' + testRunner.getResults().size().toString())

for(result in testRunner.getResults()){
	if(result.getStatus().toString() != 'PASS' ){
		def failedTestStepName = result.getTestStep().getName()
		def logPrefixStep = logPrefix.trim() + failedTestStepName + ': '
		
		log.error(logPrefixStep + 'TestStep "' + failedTestStepName + '" finished with the status ' + result.getStatus().toString())

		for(testProperty in testCase.getTestStepByName(failedTestStepName).getPropertyList()){
			if(testProperty.isReadOnly()){
				log.info(logPrefixStep + 'Output property: ' + testProperty.getName() + ' = ' + testProperty.getValue())
			}else{
				log.info(logPrefixStep + 'Input property: ' + testProperty.getName() + ' = ' + testProperty.getValue())
			}
		}
		
		for(message in result.getMessages()){
			log.error(logPrefixStep + 'Error message: ' + message) 
		}
	}
}

whenever running my test cases. I'm getting below error 

 

Thu Nov 21 15:32:05 UTC 2019: ERROR: com.eviware.soapui.support.scripting.ScriptException: Error in TestRunListener.afterRun
   com.eviware.soapui.support.scripting.ScriptException: Error in TestRunListener.afterRun
   	at com.eviware.soapui.eventhandlers.support.DefaultSoapUIEventHandler.invoke(DefaultSoapUIEventHandler.java:31)
   	at com.eviware.soapui.eventhandlers.support.AbstractEventHandlerMetaData.invokeHandlers(AbstractEventHandlerMetaData.java:80)
   	at com.eviware.soapui.eventhandlers.support.AbstractEventHandlerMetaData.invokeHandlers(AbstractEventHandlerMetaData.java:61)
   	at com.eviware.soapui.eventhandlers.impl.EventHandlersTestRunListener.afterRun(EventHandlersTestRunListener.java:36)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.notifyAfterRun(AbstractTestCaseRunner.java:360)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:212)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:1)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:154)
   	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   	at java.util.concurrent.FutureTask.run(Unknown Source)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   	at java.lang.Thread.run(Unknown Source)
   Caused by: groovy.lang.MissingPropertyException: No such property: testCase for class: Script2
   	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
   	at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:310)
   	at Script2.run(Script2.groovy:4)
   	at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:94)
   	at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:83)
   	at com.eviware.soapui.eventhandlers.support.DefaultSoapUIScript.invoke(DefaultSoapUIScript.java:42)
   	at com.eviware.soapui.eventhandlers.support.DefaultSoapUIEventHandler.invoke(DefaultSoapUIEventHandler.java:29)
   	... 12 more

I'm using readyAPI 3.0. 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Caused by: groovy.lang.MissingPropertyException: No such property: testCase for class: Script2

@arunbharath,

Try to use

context.testCase


Regards,
Rao.

View solution in original post

2 REPLIES 2
Community Hero

Re: Caused by: groovy.lang.MissingPropertyException: No such property: testCase for class: Script2

@arunbharath,

Try to use

context.testCase


Regards,
Rao.

View solution in original post

Highlighted
Occasional Contributor

Re: Caused by: groovy.lang.MissingPropertyException: No such property: testCase for class: Script2

Thanks @nmrao . works like a gem