Integrating with JUnit

1. JUnit Pro Integration

It is fairly easy to invoke the testrunner from your own JUnit-tests;

Copy all the jar files from the lib folder for ReadyAPI Installation folder in class file path. Copy the soapui-pro-5.0.0.jar (or corresponding version) from the bin folder in ReadyAPI intallation directory.

Refer API: http://support.smartbear.com/readyapi/apidocs/runners/com/smartbear/ready/cmd/runner/pro/SoapUIProTestCaseRunner.html

public void testRunner() throws Exception {
SoapUIProTestCaseRunner runner = new SoapUIProTestCaseRunner();
runner.setProjectFile("SoapUIWorkspace/Sample-soapui-project.xml");
runner.setPrintReport(true); 
runner.run();
}

The runner.run() call will throw an exception if an error occurs. If you want more control over your integration / error-reporting, a specific TestCase could be run as follows:

public void testRunner() throws Exception {
	WsdlProjectPro project = new WsdlProjectPro("SoapUIWorkspace/Sample-soapui-project.xml");
	List testSuites = project.getTestSuiteList();
	for( TestSuite suite : testSuites ) {
		List testCases = suite.getTestCaseList();
		for( TestCase testCase : testCases ) {
			System.out.println("Running SoapUI test [" + testCase.getName() + "]");
			TestRunner runner2 = testCase.run(new PropertiesMap(), false);
			assertEquals(Status.FINISHED, runner2.getStatus());
		}
	}
}

2. JUnit open source integration

It is fairly easy to invoke the testrunner from your own JUnit-tests;

public void testRunner() throws Exception 
{
  SoapUITestCaseRunner runner = new SoapUITestCaseRunner(); 
  runner.setProjectFile( "src/dist/sample-soapui-project.xml" );
  runner.run(); 
}

The runner.run() call will throw an exception if an error occurs. If you want more control over your integration / error-reporting, a specific TestCase could be run as follows:

public void testTestCaseRunner() throws Exception 
{
  WsdlProject project = new WsdlProject( "src/dist/sample-soapui-project.xml" ); 
  TestSuite testSuite = project.getTestSuiteByName( "Test Suite" ); 
  TestCase testCase = testSuite.getTestCaseByName( "Test Conversions" );
  
  // create empty properties and run synchronously
  TestRunner runner = testCase.run( new PropertiesMap(), false ); 
  assertEquals( Status.FINISHED, runner.getStatus() ); 
}

TestEngine: An Optimized Test Runner

Execute tests from SoupUI Open Source or SoupUI Pro in parallel to speed up your API Testing.

  • Scale Based on Your Business Needs:

    Dynamically run larger regression tests alongside smaller tests with custom configuration parameters.

  • Job Queuing:

    Execute tests as they arrive, staggering test runs and avoiding bottlenecks at peak times.

  • Supports Multiple Environments:

    Use TestEngine on Docker, VMS, Mac, Windows or Linux.

3. Reporting and Exporting Functional Web Service Tests

The SoapUITestCaseRunner has basic reporting functionalities, including the possibility to create JUnit-compatible xml-reports using the -j switch. Also, it will during execution print diagnostic information and if the -r switch was specified print a small summary:

testrunner.bat jbossws-soapui-project.xml -stest -ctesting -r -a -fmyresults

produced the following output:

SoapUI 1.5beta2 TestCase Runner 
12:33:10,042 INFO [SoapUITestCaseRunner] setting projectFile to [jbossws-soapui-project.xml] 
12:33:10,042 INFO [SoapUITestCaseRunner] setting testSuite to [test]  
12:33:10,042 INFO [SoapUITestCaseRunner] setting testCase to [testing] 
12:33:10,583 INFO [WsdlProject] Loaded project from [jbossws-soapui-project.xml] 
12:33:11,915 INFO [SoapUITestCaseRunner] Running soapui tests in project [jbossws] 
12:33:11,915 INFO [SoapUITestCaseRunner] Running soapui suite [test], runType = SEQUENTIAL 
12:33:11,925 INFO [SoapUITestCaseRunner] Running soapui testcase [testing] 
12:33:11,935 INFO [SoapUITestCaseRunner] runing step [Groovy Script - init boss] 
12:33:12,335 INFO [SoapUITestCaseRunner] runing step [Properties] 
12:33:12,335 INFO [SoapUITestCaseRunner] runing step [Transfer Values - set boss] 
12:33:12,716 ERROR [SoapUITestCaseRunner] Transfer Values - set boss  failed, exporting 
to [myresults\test\testing\Transfer-FAILED.txt] 
12:33:12,716 INFO [SoapUITestCaseRunner] runing step [request step] Retrieving document  
at 'http://lpt-olma:8080/ws4ee-samples-server-ejb/Organization?wsdl'.
12:33:13,407 INFO [SchemaUtils] Loading schema types from 
[http://lpt-olma:8080/ws4ee-samples-server-ejb/Organization?wsdl] 
12:33:13,407 INFO [SchemaUtils]  Getting schema 
http://lpt-olma:8080/ws4ee-samples-server-ejb/Organization?wsdl
12:33:13,787 INFO [SoapUITestCaseRunner] Assertion [Schema Compliance] has status VALID 
12:33:13,807 INFO [SoapUITestCaseRunner] Finished running soapui testcase [testing], time taken = 1882ms 
12:33:13,807 INFO [SoapUITestCaseRunner] Skipping testcase [testcase2], filter is [testing] 
12:33:13,807 INFO [SoapUITestCaseRunner] Skipping testcase [Copy of  testing], filter is [testing] 
12:33:13,807 INFO [SoapUITestCaseRunner] Skipping testcase [Copy of  Copy of testing], 
filter is [testing] 
12:33:13,807 INFO [SoapUITestCaseRunner] soapui suite [test] finished in 1892ms

SoapUI 1.5beta2 TestCaseRunner Summary
----------------------------- 
Time Taken: 1895ms
Total TestSuites: 1 
Total TestCases: 1 
Total TestSteps: 4 
Total Request Assertions: 1 
Total Failed Assertions: 0 
Total Exported Results: 4

By default, the testrunner exports only failed results to a text file, the -a option will export all results instead. For example the file for a Request TestStep will be as follows (slightly modified to fit):

Status: OK
Time Taken: 55
Size: 448
Timestamp: Sun Mar 12 12:45:57 CET 2006
TestStep: request step
----------------------------------------------------
Encoding: UTF-8
Endpoint: http://lpt-olma:8080/ws4ee-samples-server-ejb/Organization
Username: test
Password: zswrgfa3
Domain: 
---------------- Request ---------------------------
<soapenv:Envelope xmlns:sam="http://org.jboss.test.webservice/samples" 
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <sam:getContactInfo>
         <String_1>testsd1141581163341</String_1>
      </sam:getContactInfo>
   </soapenv:Body>
</soapenv:Envelope>
---------------- Response --------------------------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <ns1:getContactInfoResponse xmlns:ns1="http://org.jboss.test.webservice/samples">
         <result>The 'testsd1141581163341' boss is currently out of office, please call again.</result>
      </ns1:getContactInfoResponse>
   </soapenv:Body>
</soapenv:Envelope>

Exported files are written to a file named <TestSuite>-<TestCase>-<TestStep Name>-<Count>-<Status>.txt in the current or specified folder. An example filename is "TestSuite 1-TestCase 1-Request Step 1-0-OK.txt" (the count is added since a TestStep can be invoked several times within the run of a TestCase). As of soapUI 1.7.5, response attachments are also exported, named <TestSuite>-<TestCase>-<TestStep Name>-<Count>-attachment-<AttachmentCount>.<Extension>, where the extension is created from the attachments content-type if possible (otherwise .dat will be used)