Running a test case of different project in a same workspace using maven soapui plugin in java
Hi,
I have a project A in which i am running a groovy to call a test case of another project B in same workspace. When I run it in SoapUI 5.3 UI it works OK but in java using maven soapui plugin it is not working.
Project A (PriceQuoteService-Tests-soapui-project) test step:
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.model.project.ProjectFactoryRegistry
import com.eviware.soapui.impl.wsdl.WsdlProjectFactory
import com.eviware.soapui.impl.WorkspaceImpl;
import java.io.File
def session = testRunner.testCase.testSuite.getPropertyValue("Session")
log.info session
def filePath
def groovyUtils=new com.eviware.soapui.support.GroovyUtils(context)
def os = System.getProperty("os.name").toLowerCase();
log.info os
if(os.indexOf("win")>=0){
filePath = groovyUtils.projectPath + "\\" + "SharedTests-soapui-project.xml"
}
else if(os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 || os.indexOf("mac") >= 0){
filePath = groovyUtils.projectPath + "/" +"SharedTests-soapui-project.xml"
}
else{
filePath = groovyUtils.projectPath + "/" +"SharedTests-soapui-project.xml"
}
// Printing the value of the variable
log.info filePath
def workspace = context.testCase.testSuite.project.workspace
def testProject = (workspace==null) ? ProjectFactoryRegistry.getProjectFactory(WsdlProjectFactory.WSDL_TYPE).createNew(filePath) : workspace.getProjectByName("SharedTests")
if(!testProject.open && workspace!=null) workspace.openProject(testProject)
WsdlTestCase testCase = testProject.getTestSuiteByName("SharedTests").getTestCaseByName("SetUp_GDS")
testProject.properties["Session"].value = session
TestRunner runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
Project B (SharedTests-soapui-project) test case
Java code to run project A:
WsdlProject project = new WsdlProject(project A xml path);
File projectfile = new File(projectxmlpath);
String parent = projectfile.getParent();
File ws = new File(parent + File.separator + "default-soapui-workspace.xml");
WorkspaceImpl wsimpl = new WorkspaceImpl(parent + File.separator + "default-soapui-workspace.xml", null);
wsimpl.loadWorkspace(ws);
WsdlTestCaseRunner wsRunner = project.getTestSuiteByName(testSuiteName).getTestCaseByName(testCaseName).run(new PropertiesMap(), false);