SoapUI JUnit MockRunner Tests

Testing the JUnit rule from outside.

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

io.fares.junit.soapui
ArtifactId

ArtifactId

soapui-junit-mockrunner-tests
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

SoapUI JUnit MockRunner Tests
Testing the JUnit rule from outside.

Download soapui-junit-mockrunner-tests

How to add to project

<!-- https://jarcasting.com/artifacts/io.fares.junit.soapui/soapui-junit-mockrunner-tests/ -->
<dependency>
    <groupId>io.fares.junit.soapui</groupId>
    <artifactId>soapui-junit-mockrunner-tests</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/io.fares.junit.soapui/soapui-junit-mockrunner-tests/
implementation 'io.fares.junit.soapui:soapui-junit-mockrunner-tests:0.0.3'
// https://jarcasting.com/artifacts/io.fares.junit.soapui/soapui-junit-mockrunner-tests/
implementation ("io.fares.junit.soapui:soapui-junit-mockrunner-tests:0.0.3")
'io.fares.junit.soapui:soapui-junit-mockrunner-tests:jar:0.0.3'
<dependency org="io.fares.junit.soapui" name="soapui-junit-mockrunner-tests" rev="0.0.3">
  <artifact name="soapui-junit-mockrunner-tests" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.fares.junit.soapui', module='soapui-junit-mockrunner-tests', version='0.0.3')
)
libraryDependencies += "io.fares.junit.soapui" % "soapui-junit-mockrunner-tests" % "0.0.3"
[io.fares.junit.soapui/soapui-junit-mockrunner-tests "0.0.3"]

Dependencies

test (7)

Group / Artifact Type Version
io.fares.junit.soapui : soapui-junit-mockrunner jar 0.0.3
commons-io : commons-io jar 2.4
org.slf4j : slf4j-api jar 1.7.2
org.slf4j : jcl-over-slf4j jar 1.7.2
org.slf4j : jul-to-slf4j jar 1.7.2
org.slf4j : slf4j-log4j12 jar 1.7.2
log4j : log4j jar 1.2.17

Project Modules

There are no modules declared in this project.

SoapUI JUnit MockRunner

Overview

Ever tried to start a soapui mock service from within your junit test? Sure the soapui-maven-plugin make a good job when you just run from command line ... but if you develop in an IDE that is not always the case.

This module can be used to execute a soapui mock service within a classloader jail. This will ensure the project under test is not dependent on SoapUI itself. The classloader jail will resolve all required dependencies from the official soapui maven repository.

Example

The most simple example on how to fire up a Junit test with a SoapUI mock service running in the background.

import static org.junit.Assert.*;
import org.junit.ClassRule;
import org.junit.Test;

public class SomeMockServiceTest {

  @ClassRule
  public static SoapUIMockRunner runner = new SoapUIMockRunner()
                                                  .simpleBinding()
                                                  .withProjectPath("embedded-soapui/TestSoapUIProject-soapui-project.xml")
                                                  .withMockServiceName("WeatherMockService")
                                                  .withMockHost("localhost")
                                                  .withMockPort(8097)
                                                  .withMockPath("/weather-change");

  @Test
  public void testMockRunner() throws Exception {
    assertTrue(runner.isRunning());
    System.out.println("do some testing against endpoint: " + runner.getMockEndpoint());
  }

}

Configure SoapUI Version

Because the soapui starts in a classloader jail, one can also a) compile this libary against a different version:

mvn clean install -Dsoapui.version=5.1.2

or if the compiled version of soapui-junit-mockrunner is largely compatible with what you are trying to run, simply specify the version on the SoapUIMockRunner:

new SoapUIMockRunner()
        .simpleBinding()
        .withProjectPath("embedded-soapui/TestSoapUIProject-soapui-project.xml")
        .withMockServiceName("WeatherMockService")
        .soapuiVersion("5.1.2");

The option is risky when you specify a runner version that is incompatible with the soapui classes that are loaded.

I sucessfully ran a soapui-junit-mockrunner compiled against SoapUI 5.0.0 using a 5.1.2 runtime version (as above example).

TODO

Instead of the dodgy simple binding, should really use com.eviware.soapui.tools.SoapUIMockServiceRunner.main() with a set of standard SoapUI path parameters.

Limitiations

  1. the reflection binding does not work with path, port and host settings (use simple binding)
  2. searching for the local maven repo for cached artefact bindings is rather crude
  3. need to improve exception handing, especially with the rule
  4. not enough tests and examples

Versions

Version
0.0.3
0.0.2