TommyTester
5 years agoOccasional Contributor
Groovy script to open Project
Hi,
I'm writing a Groovy script step to run a test case that is within another project (Project 1 in the code snippet below). This code works if Project 1 is already open, however it fails on the second line if Project 1 is not open, for example if being run via TestRunner.
def project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Project 1")
def testSuite = project.getTestSuiteByName("Test Suite Name")
def testCase = testSuite.getTestCaseByName("Test Case Name")
def runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
Is there a way to load Project 1 if it isn't already open?
Here's a quick snippet you may be able to use.
def workspace = context.testCase.testSuite.project.workspace; def project = workspace.getProjectByName("PROJECTNAME"); if (project.isOpen() == false) { workspace.openProject(project); }