Ask a Question

How can i run a project in other workspace using groovy script?

SOLVED
jerr
Occasional Contributor

How can i run a project in other workspace using groovy script?

I have project1 in workspace1 and project2 in workspace2. From project2 i want to run a test suite in project1 using groovy script.

 

Your help is appreciated.

4 REPLIES 4
nmrao
Community Hero

What is your use case? why do you want do so while it is easy to run the project either from workspace or from command line utility testrunner?


Regards,
Rao.
jerr
Occasional Contributor

My use case is that I wanted to put two projects in two different workspace. From project 1 I wanted to be able to run project 2. Is it possible to do that?

Thanks for your suggestion. I will definitely do as you said if what I planned is not possible.

I'm not totally sure if this is what you are needing but I use this to run another project after the first project has completed. I add this code as the teardown script of the project suite.

 

import com.eviware.soapui.impl.wsdl.WsdlProject
def project = null
projectPath=context.expand('${projectDir}')
def workspace = testSuite.project.getWorkspace();
try{
if(workspace != null){
project = workspace.getProjectByName("Project2")
project = new WsdlProject(projectPath+"/Project2-soapui-project.xml");
}
//if running in Jenkins/Hudson
else{
project = new WsdlProject(projectPath+"/Project2-soapui-project.xml");
}
}
catch(Exception e)
{
log.error("Service Exception desc : " + e.getMessage());
}

try{
if(project.open && project.name == "Project2" ) {
def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
def testCase = project.getTestSuiteByName("Project2_TestSuite").getTestCaseByName("Project2Case");
if(testCase == null)
{
throw new RuntimeException("Could not locate testcase 'Project2Case'! ");
}
else{

testCase.setPropertyValue("projectPath_1", projectPath )
def runner = testCase.run(properties, false);
}
}
else{
throw new RuntimeException("Could not find project 'Project2' !")
}
}
catch(Exception e)
{
log.error("Service Exception desc : " + e.getMessage());

}

project = null

jerr
Occasional Contributor

Thanks Bagochips, I did it from the command line as nmrao suggest.

cancel
Showing results for 
Search instead for 
Did you mean: