Sorry to bother you again, I have a question on assertion please
I use SoapUI Pro (and am testing API Ready now) to do functional test on medical rules, here's a simple example:
Medical Rule 123: A child who's 2 years old should have MMR vaccine
In the xml request I offer a child's date of birth, ruleID=123, if the child is 2 years old (as of today), it displays the ruleID of123 in the response and send an alert to the child's doctor, if the child is not 2 years old, it doesn't display the ruleID and no alert is generated
For the data source I use Excel spreadsheet like:
DOB RuleID isEligible
2013-01-01 123 true --- 2 years old
2014-01-01 123 false --- not 2 years old
2013-01-02 123 false --- 2 years old
I've created the related properties "DOB" and "ruleID" for data driven test, and I'd like to add an assertion on ruleID in response, if I have ruleID 123 displayed in response then the child is eligible for vaccine
I was thinking to use "contains" (for ruleID=123) assertion, for the above 1st child, the response contains ruleID=123, so the child is eligible for vaccine, and since I set isEligible to true, this test case should pass; for the 2nd child, the response doesn't contain ruleID=123, so the child is not eligible and since I set isEligible to false, this test case should also pass; the 3rd child is also 2 years old but I set isEligible to false, so this test case should fail
How do I implement "isEligible" comparing with the assertion result please?
Thanks a lot for help
Thanks a lot to take a look at my post, please find the following example
------ Request -----
---- Response (Eligible) ----
<NDSatientAge>2 years 11 months</NDSatientAge>
If DOB in request = 2014-01-01, then the non eligible response would be:
I use Excel spreadsheet or Oracle JDBC connection as data source, running test is no problem at all, but the question is how I could do the assertion to associate with the preset value in the source for eligibility, for example, today is Dec. 11, 2015, a tester can set the following values in the spreadsheet to validate if this rule works correctly
DOB RuleID isEligible <--- Header in the spreadsheet
2013-12-11 123 true <--- test step 1: the child is 2 years old, he/she is eligible
2013-12-12 123 false <--- test step 2: the child is NOT 2 years old, he/she is not eligible
2013-12-11 123 false <--- test step 3: the child is 2 years old and is eligible, but the value is false for eligibility, so this test step should fail
For test step 1, the child is 2 years old and is eligible, the node "<NDS:ruleID>123</NDS:ruleID>" is displayed in the response, and since the presetting of "isEligible" in the spreadsheet is "true" and fits the eligible response, so this test step should pass
For test step 2, the child is not 2 years old and is not eligible, the node "<NDS:ruleID>123</NDS:ruleID>" is not displayed in the response, since the value for eligibiliety is "false" and fits the non eligible response, so this test step should also pass
For test step 3, the child is 2 years old and is eligible, but the value is "false" and doesn't fit its eligible response, so this test step should fail
Basically the DOB data is the only one I need for testing, the rest are for eligibility so they really don't matter if, how or what to be in the data source, as long as the logic works.
I try to find a practical way to do assertion on eligibility
Thanks a lot for help
Please see this thread, orginated from you. There it is was given how to get the date difference or how to get the years in difference.
So, you need to see
if isEligible is true then it must satisfy years >=2
if years >= 2 then, check for other values from the response that needs to be asserted
else then assert status must zero, and session is not null.
Thanks a lot for your reply, yes, I used your code in calculating dates and it worked perfectly.
At first, I was expecting some element for eligibility in the response so I could easily add assertion but our developers coded in a different way, when eligible the response displays the ruleID; when not eligible the response doesn't display ruleID, so I consider the existence of the node like:
def holder = new XmlHolder( messageExchange.responseContentAsXml )
holder.namespaces["NDS"] = "XXXXXX"
def node = holder.getDomNode( for ruleID )
assert node != null
But then the problem is, if I do "assert node != null", all test steps for non-eligible status will fail, we actually don't want them fail, we want them pass but with some indication that the patient is not eligible, so we'd like to use a variable or something to hold the status of eligibility (or ruleID since it only displays if eligible). My plan is that I give a DOB and a value for status in the data source, when I run a test step, if there's the ruleID in the response, or such a node, the status is true, then compares with the value in the data source, if they are the same, the test step passes, for example:
I give "DOB1, true" in data source, here DOB1 is older than 2 yrs old, the response displays ruleID, maybe a script set a status varaible to be true, then compares with the "true" in the data source, since they are the same, the test step passes. If I give "DOB2, false" in data source, here DOB2 is less than 2 yrs old, the response doesn't display the ruleID, the node is missing, so the script set status to be false, then compares with the "false" in the data source, since they are the same, the test step passes, a test step should only fail when its output status is different from the status in the data source, which means either the rule calculates wrong, or our logic is wrong (typical for negation test)
Please keep in mind, we test a rule as black box, we can only conclude based on the output (response), since the response doesn't display anything if not eligible (except a missing node), that makes the assertion difficult, also, this is a bit out of assertion aspect, do you have any suggestion or recommendation in coding this kind of script please?
Thanks a lot
I'm sorry if I confused you, I'll put it in a simple way
I'd like to test a rule with Excel spreadsheet or Oracle database as data source (patients' DOBs), this rule only takes DOB as input and outputs either the ruleID (if eligible) or nothing (if not eligible) in the response, the question is, how do I assert on a missing node (for non eligible situation) please? I did find an example on how to assert on null value in this forum though, wonder if you could shed some light on missing node please