JUnit and SoapUI Integration

JUnit and SoapUI Integration example.

groovy:
========================
def xpathAssertion = testRunner.testCase.testSteps["name_of_your_step"].addAssertion("XPath Match")
xpathAssertion.setPath("your_xpath")
xpathAssertion.setExpectedContent("expected_result")
xpathAssertion.setName("your_required_name_xpath")

def containsAssertion = testRunner.testCase.testSteps["name_of_your_step"].addAssertion("Contains")
containsAssertion.setToken("your_expected_string")
containsAssertion.setName("your_required_name_contains")

JUnit:
=========================
WsdlProject project = new WsdlProject(PropertiesFactory.getString("SOAPUI_PROJECT_FILE_PATH"));
List<TestSuite> testSuiteList = project.getTestSuiteList();
for(TestSuite testSuite : testSuiteList){
List<TestCase> testCaseList = testSuite.getTestCaseList();
for(TestCase testCase : testCaseList){
String testCaseName = testCase.getName();
String testCaseProperties = PropertiesFactory.getString("SoapUIProject", testCaseName);
testCase.setPropertyValue("assertions", testCaseProperties);
//testCase.setPropertyValue("assertions",  "[\"NewOperation\", \"My_xpath_match1\", \"XPath Match\", \"//*[local-name()='ReversedString']\", \"DCBA\"]");
TestRunner testCaseRunner = testCase.run(new StringToObjectMap(), false);
assertEquals( TestRunner.Status.FINISHED, testCaseRunner.getStatus( ));

}
}

Properties:
=========================
assertion2=NewOperation, My_xpath_match1, XPath Match, //*[local-name()='ReversedString' and namespace-uri()==${rev}]







你可能感兴趣的:(JUnit)