Forum Discussion

678's avatar
678
Regular Contributor
6 years ago
Solved

Script Error - getTestCaseByName

Can any one help here belo is my script 

 

Script

 

import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus
import com.eviware.soapui.model.testsuite.TestRunner.Status
import com.eviware.soapui.model.project.ProjectFactoryRegistry
import com.eviware.soapui.impl.wsdl.WsdlProjectFactory
import com.eviware.soapui.impl.wsdl.*
import com.eviware.soapui.impl.wsdl.testcase.*
import com.eviware.soapui.model.testsuite.*
import com.eviware.soapui.model.support.PropertiesMap;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner
import com.eviware.soapui.impl.WorkspaceImpl;
import java.io.File

 

 


def Workspace = testRunner.getTestCase().getTestSuite().getProject().getWorkspace()
def Project = (Workspace==null) ?

ProjectFactoryRegistry.getProjectFactory(WsdlProjectFactory.WSDL_TYPE).createNew('$Workspace') :
Workspace.getProjectByName("Automation")

if(!Project.open && Workspace!=null) Workspace.openProject(Project)

def datasource = context.expand( '${DataSource#set}' )

 


def Lib = Project.getTestSuiteByName("Library");


testCase = Lib.getTestCaseByName("TC_CreateAccount");

log.info "testcase Name="+testCase
 

 

Error : 

ERROR [errorlog] An error occurred in the script of the Groovy Script test step [GroovyScript2]:
 ERROR [errorlog] java.lang.NullPointerException: Cannot invoke method getTestCaseByName() on null object

 

 

  • nmrao's avatar
    nmrao
    6 years ago
    Looks author of the question is not bothered about providing the requested info.

8 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    One should refrain using workspace object if automation needs to be achieved.

     

    And the use case please?

    • Lucian's avatar
      Lucian
      Community Hero

      Hey,

       

      Where is the script placed? Is it in a groovy script step? Why do you need to get the workspace?

      • 678's avatar
        678
        Regular Contributor

        Lucian

         

        Script placed in Events as a groovy script 

         

        TestRunListner.afterstep

         

         

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi 678,

     

    Did the suggestion given here point you in the right direction to find a solution?