Forum Discussion

_ivanovich_'s avatar
_ivanovich_
Frequent Contributor
5 years ago

Groovy Calling method returns error

Hi,

i have a file test1.groovy in the soapui project path

in soapui i have a groovy code named test2

test1.groovy

import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus
import groovy.sql.Sql
import java.sql.ResultSet;


public class groovyUtilities {
def context
def testRunner
def log
def Getdata() {
def id = testCase.testSuite.project.setPropertyValue("idx","abc")

log.info id
}

 

in test2

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def projectPath = groovyUtils.projectPath
def scriptPath = projectPathGroovyScriptEngine gse = new GroovyScriptEngine(scriptPath)
externalScript = gse.loadScriptByName("test1.groovy")
instance = externalScript.newInstance(context:context, log:log, testRunner:testRunner)
assert instance != null

instance.GetData()

When i run test2 it returns:

groovy.lang.MissingPropertyException: No such property: testCase for class: groovyUtilities

 

What is missing here?

Thank you

4 Replies

  • _ivanovich_'s avatar
    _ivanovich_
    Frequent Contributor

    The code returns error because i'm soapui open source?

    Will it work in soapui pro?

    Thank you

    • nmrao's avatar
      nmrao
      Champion Level 3
      Because the testCase property is not available in the class.
      • _ivanovich_'s avatar
        _ivanovich_
        Frequent Contributor

        The testCase property is not available in the class.

        How can we resolve this probleme? Should i add some librairies?

        Did i miss something in my code? or is it because i'm not using the pro version?