Since SoapUI is a Java application, test suites can be invoked directly from JUnit removing the need for human intervention. On my GitHub page, I've uploaded a project that demonstrates how to do this. The project has a JUnit test case that launches a SoapUI mock Web Service and then invokes the test suite for it. Let me give a brief overview on how I went about developing the project.
The first step was to set up a SoapUI project and test suite based on a WSDL. There's plenty of documentation online on how to do this. In the test suite, I created a test case for each WSDL operation:
For every test case, I asserted that the SOAP response isn't a SOAP fault, complies with the schema, it's a valid SOAP response and the outcome of the operation is correct:
Now it was time to start developing the JUnit test case. I could have imported into my Java project the SoapUI libraries from the SoapUI distribution. But being a sadist, I decided to use Maven : P. In the project's POM, I declared the repo where to find SoapUI and its dependencies:
I then declared the dependencies that I want to be retrieved and included in the classpath:
The last step was to write the test for my Web Service:
testCalculatorService is annotated with @Test which instructs the JUnit runner to execute the test. What the test does is simple:
- It loads the test suite and mock Web Service configurations from the SoapUI project calculator-soapui-project.xml
- Launch the mock Web Service
- Execute the test suite