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
Hi, first of all thanks for your post, I found it very useful, but I would like to point out that I also needed to add the following dependencies to the pom.xml to solve some other classnotfound errors:
ReplyDeletecommons-cli
commons-cli
1.2
test
javax.mail
mail
1.4
test
javax.servlet
servlet-api
2.5
test
commons-beanutils
commons-beanutils
1.8.3
test
net.sf.saxon
saxon-dom
8.7
test
Thanks Claude and Fran! I've fixed dependencies in forked repository
Deletehttps://github.com/stokito/soapui-junit