Ask a Question

Script Error - getTestCaseByName

SOLVED
678
Regular Contributor

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
nmrao
Community Hero

Re: Script Error - getTestCaseByName

Looks author of the question is not bothered about providing the requested info.


Regards,
Rao.

View solution in original post

8 REPLIES 8
nmrao
Community Hero

Re: Script Error - getTestCaseByName

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

 

And the use case please?



Regards,
Rao.
Lucian
Community Hero

Re: Script Error - getTestCaseByName

Hey,

 

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



If my answer helped please click on the 'Accept as Solution' button.
TanyaYatskovska
Community Manager

Re: Script Error - getTestCaseByName

Hi @678,

 

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

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
678
Regular Contributor

Re: Script Error - getTestCaseByName

@Lucian

 

Script placed in Events as a groovy script 

 

TestRunListner.afterstep

 

 

TanyaYatskovska
Community Manager

Re: Script Error - getTestCaseByName

Guru experts, What can we suggest here?

 

@Lucian@nmrao@msiadak@richie@avidCoder

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Lucian
Community Hero

Re: Script Error - getTestCaseByName

I have in plan to take a look at it later today.



If my answer helped please click on the 'Accept as Solution' button.
msiadak
Community Hero

Re: Script Error - getTestCaseByName

I think to propery troubleshoot this I would need to see at least a screenshot of the project so we can see the layout of the test suites / test cases / etc. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
nmrao
Community Hero

Re: Script Error - getTestCaseByName

Looks author of the question is not bothered about providing the requested info.


Regards,
Rao.

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: