How to associate the response with the expected result (in data source) please?
I'm testing a simple medical rule, basically this rule requires a patient to visit his/her doctor for the second time AFTER he/she finishes the prescription medicine, for example:
1) Today the patient visited the doctor again, if the prescription date was 10 days ago and the amount is 7 (1 med per day), then today the patient already finished the medicine, so the patient is compliant
2) Today the patient visited the doctor again, if the prescription date was 10 days ago and the amount is 14 (1 med per day), then today the patient still has 4 medicine, so the patient is not compliant
So my data source shows "prescription_date" and "prescription_amount" (data driven testing), the run date is today, the engine processes the above situation and if the patient is compliant, it displays in the response: isCompliant = true, otherwise it shows isCompliant = false
When we test this rule as a black box, we give only "prescription_date" and "prescription_amount" in spreadsheet or in database, the element "isCompliant" is only displayed in the response after engine processes the request, the element "isCompliant" is not in the request.
If possible, we'd like to add the expected result (maybe in data source) to compare with actual result of isComplaint in order to validate if the rule is processed correctly, the question is, how do we associate them please? As properties? Or assertion? Or through script?
Suppose we have the data source below (today is Dec.15, 2015, 10 days ago was Dec. 5, 2015)
prescription_date prescription_amount (expected_result) -- I use ( ) because I'm not sure if it's practical
12/05/2015 7 (true)
12/05/2015 10 (false)
prescription_date and prescription_amount will be passed to request as properties, but how do we associate the "expected_result" with the actual result "isCompliant" in the response please? Or how do we assert on isCompliant in the response to associate with the expected_result in the data source or elsewhere please? I'm open to all your possible solution or recommendation.
Thanks again for help
Jerry
Hi Jerry,
you could do this in SoapUI via groovy script. You need 4 steps in your TestCase:
1. DataSource
2. Soap-call
3. Groovy-script for checking the result from the saop-call with your expected result (see below)
4. DSL to get to the start of the loop again
Your groovy script could look like this:
import com.eviware.soapui.support.XmlHolder;
def assertionList = [];
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def holder = groovyUtils.getXmlHolder(testRunner.testCase.testSteps["<name of the saop-teststep to be executed>"].testRequest.response.getContentAsXml());// get the result from the soap call
def soap_result = holder.getNodeValue("<xpath to the tag which holds the result>");// get the expected result from the datasource
def ds = testRunner.testCase.testSteps['DataSource']; // name of the datasource
def dsExpectedResult = ds.getPropertyValue("<name of the column in the datasource which contains the expected result>");// compare expected with actual result
if ( dsExpectedResult != soap_result )
log.info(" Actual and expected result do not match.");
Thanks a lot for the great help!
Jerry