Running mocks and tests using Java and JUnit
Running SoapUI mocks and tests from Java and JUnit is relatively easy to do, as we essentially run the same Java classes that the command line and Maven plugins use. In the first part of this recipe, we will look at running the SoapUIMockServiceRunner
and SoapUITestCaseRunner
files directly. Then, we will look at doing the same via a JUnit runner.
Getting ready
In both cases, we'll run the SOAPMock-soapui-project.xml
project as before. All the code is contained in the chapter 5
samples' /java/
folder.
The samples are easy to run from Eclipse (or a similar IDE) and also from the command line. The minimum you need is a SoapUI and a JDK (this recipe uses JDK 1.7.x).
Unless you're using an IDE, which bundles JUnit, you might need to download the JUnit library (junit-4.11.jar
is also included in the /java/
chapter 5 samples folder).
How to do it...
First, let's look at how to start the mock and run tests against it using Java. Then, we can run the same code...