Forum Discussion

P__1's avatar
16 years ago

SOAPUI Junit

I would like to test a Web Service from the JUnit using the xml file into which the test suites are extracted.

I use WsdlProject project = new WsdlProject("src/com/test/soapui/soapui-test.xml") to enable test of the web service using java.

The problem I am facing is that the host of web service can change with time. Can I reset the endpoint of the service in the Junit ?.

2 Replies

  • b6429527's avatar
    b6429527
    New Contributor
    It would also be interested in me:

    [tt:2rv0y2v1]WsdlTestSuite testSuite = project.getTestSuiteByName("Test Suite Name");
    WsdlTestCase testCase = testSuite.getTestCaseByName("Test Case Name");

    StringToObjectMap properties = new PropertiesMap();
    WsdlTestCaseRunner testRunner = testCase.run(properties, false);[/tt:2rv0y2v1]

    It probably goes through the properties, but they are not documented anywhere .
  • b6429527's avatar
    b6429527
    New Contributor
    Ok, I found solution by SoapUITestCaseRunner:

    [tt:1jzbn7z6]SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
    runner.setEndpoint("http://myserver:9001");
    runner.setOutputFolder("target/soapui-errors");
    runner.setProjectFile(projectXmlFile);
    runner.setTestSuite(testSuiteName);
    runner.setTestCase(testCaseName);

    try {
    runner.run();
    } catch (Exception ex) {
    throw new AssertionError(buildTestCaseReport(testCase, testRunner) + " " + ex.toString());
    }[/tt:1jzbn7z6]

    It's a bad solution, because I can not cache the project xml and load test takes a long time. But other solutions did not work.

    Boys, it needs more documentation!