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?
Solved! Go to Solution.
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);
}
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);
}
While I understand the intent of that rule of thumb, @nmrao, I am curious if that's one you try to live by or if that's a standard that's been laid out somewhere? The only reason I ask is where I work, that was actually something I was not able to do all the time. Some projects had to be developed separately to match requirements, and while it made my life harder I had to work around said requirements of my job.
We use a series of "helper" steps to assist with data setup etc. We don't want to maintain these across multiple projects, and would rather keep them in one centralized place that can be called from multiple projects.
Is there a solution so that workspace doesn't have to be used?
User | Count |
---|---|
4 | |
3 | |
2 | |
1 | |
1 |
Subject | Author | Latest Post |
---|---|---|