automation, java, SDET, soapUI

SoapUI Assessment – The Cloanto Currency Server

Introduction to the assessment

Hello there Tester,

A currency exchange company uses a server to provide the latest exchange rate information and conversions as a service.  It holds forty two operations for customers to query and they would like you to create tests for some of these operations.  

Today your job is to provided test cases using SoapUI for some of the real world scenarios our company are currently facing.

You should solve the problem using SOAP UI Standard (FREE) version, answers using SoapUI Pro are out of the scope today. 

Pre-Requisite

Import the WSDL into SoapUI from the following location:

http://fx.cloanto.com/webservices/CloantoCurrencyServer.asmx?WSDL

Screen Shot 2017-04-14 at 12.51.04

Fig 1: Imported WSDL

Figure 1 shows you what your project should look like.  Take time to familiarise yourself with the operations available and when you feel ready, begin creating your tests.

The SoapUI Test Scenarios

To help you get going, our Product Owner have prepared a set of scenarios that your testing techniques should be applied, they are:

Scenario 1:

Employees are not expected to learn every single currency code.  Devise a test that can return the full currency name for any currency code, this should be an input parameter.

 

Scenario 2:

A UK businesswoman trades currencies with Germany and uses the service regularly to check the value of Germany’s currency. Create a test that will check that the service returns a value and store it. 

 

Scenario 3:

A couple will be travelling to the United States of America and are keeping a close eye on the value of the dollar.  They want to purchase £500 worth of dollars, only if the amount of dollars is greater than $800.  The test condition should fail based on these conditions.

 

Scenario 4:

The company has a list of all currencies that they deal with.    Create a properties file containing the first five currencies and use that file to drive a test that will check each currency appears in the response.

 

Solution:

The solution for this challenge is quite tricky, it involves several steps and the resolution for the step 4 using SoapUI OpenSource version will require you to code some Groovy scripts in order to be able to finish the assessment.

You are finished when you have 3 passing and 1 failing:

test-result-mini

The resolution for all the steps you should be able to do it yourself, so I will only focus to explain the Test 4 and the parts involved.

How to pass properties to a request in SoapUI Free?

In SoapIU Pro, this is a easy task, however if you are a non-profit or just cheap developer who don’t like to pay anything, the resolution for some problems will require some Groovy coding skills.

So, How do I to pass properties to a request using SoapUI ? How do I use Groovy with SoapUI ?

The Test 4 involves passing properties into a action and executing it, so the following Groovy code will do the trick:

// Define the array
def paramList = [];
def projectDir = context.expand('${projectDir}');

// open the property file and store the contents in memory
new File( projectDir, "scenario_4_list_currencies.properties" ).eachLine { line -> paramList.add( line ) };

// Loop through each item in the array
for ( i in paramList ) {

 // Execute the myRequest TestStep
 log.info("will send the request using param value: " + i); 
 def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
 def testCase = testRunner.testCase;
 
 def testStep = testCase.getTestStepByName("myRequest");

//open the soapUI testcase and create a testRunner variable 
 testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
 //open the soapUI testStep
 testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
 //run the testRunner manually inserting the parameters from the property files on the scope
 //so the test will perform with no error when comparing contains
 testStep.run(testRunner, testStepContext);
}

Complete Code:

You can find this and more examples on SouJava Github – Complete Assessment

Cheers,

Thomas Modeneis.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s