Forum Discussion
Neustar
14 years agoOccasional Contributor
I am directly invoking the SOAP UI testcase and the testcase fails. My further debugging indicated that the testcase failed due to an assertion failing. The assertion as I stated earlier fails only when the testcase is invoked from java and not when the testcase is invoked through soap ui. Below is how I invoke the testcase from java and get results back.
project = new WsdlProject(
"testdata/soapui-project.xml");
testSuite = project.getTestSuiteByName(testSuiteName);
testCase = testSuite.getTestCaseByName(testCaseName);
testSuite.setPropertyValue("accountid",
TestContext.context.get("soapAccountId").toString());
for (Map.Entry<String,String> entry : map.entrySet()) {
testSuite.setPropertyValue(entry.getKey(), entry
.getValue());
}
for (TestStep testStep : testCase.getTestStepList()) {
if (testStep instanceof WsdlTestRequestStep) {
((WsdlTestRequestStep) testStep).getTestRequest().setUsername(
TestContext.context.get("soapUsername").toString());
((WsdlTestRequestStep) testStep).getTestRequest().setPassword(
TestContext.context.get("soapPassword").toString());
((WsdlTestRequestStep) testStep).getTestRequest().setEndpoint(
TestContext.context.get("soapUrl").toString());
}
}
runner = testCase.run(null, false);
if (runner.getStatus() == com.eviware.soapui.model.testsuite.TestRunner.Status
.valueOf("FINISHED")) {
return true;
} else {
logger.info("Test not passed because {} ",
new Object[] { runner.getReason() });
System.out.println("Reason for failure is " + runner.getReason());
return false;
}
project = new WsdlProject(
"testdata/soapui-project.xml");
testSuite = project.getTestSuiteByName(testSuiteName);
testCase = testSuite.getTestCaseByName(testCaseName);
testSuite.setPropertyValue("accountid",
TestContext.context.get("soapAccountId").toString());
for (Map.Entry<String,String> entry : map.entrySet()) {
testSuite.setPropertyValue(entry.getKey(), entry
.getValue());
}
for (TestStep testStep : testCase.getTestStepList()) {
if (testStep instanceof WsdlTestRequestStep) {
((WsdlTestRequestStep) testStep).getTestRequest().setUsername(
TestContext.context.get("soapUsername").toString());
((WsdlTestRequestStep) testStep).getTestRequest().setPassword(
TestContext.context.get("soapPassword").toString());
((WsdlTestRequestStep) testStep).getTestRequest().setEndpoint(
TestContext.context.get("soapUrl").toString());
}
}
runner = testCase.run(null, false);
if (runner.getStatus() == com.eviware.soapui.model.testsuite.TestRunner.Status
.valueOf("FINISHED")) {
return true;
} else {
logger.info("Test not passed because {} ",
new Object[] { runner.getReason() });
System.out.println("Reason for failure is " + runner.getReason());
return false;
}