Forum Discussion

jshu's avatar
jshu
Occasional Contributor
9 years ago

A question on assertion please

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

 

Jerry

 

5 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Description little confusing? Can please add the request and response sample xmls?
    • jshu's avatar
      jshu
      Occasional Contributor

      Thanks a lot to take a look at my post, please find the following example

       

      ------ Request -----

       

       <NDS:patientID>1</NDS:patientID>

      <NDS:dateOfBirth>2013-01-01</NDS:dateOfBirth>

      <NDS:ruleID>123</NDS:ruleID>

      <NDS:ruleDesc>MMR Vaccine</NDS:ruleDesc>

      <NDS:runDate>now()</NDS:runDate>

       

      ---- Response (Eligible) ----

       

      <NDS:ruleID>123</NDS:ruleID>

      <NDS:ruleDesc>MMR Vaccine</NDS:ruleDesc>

      <NDS:patientAge>2 years 11 months</NDS:patientAge>

      <NDS:matchClassName>Age</NDS:matchClassName>

      <NDS:status>0</NDS:status>

      <NDS:sessionID>D3236B42A5DCF03A</NDS:sessionID>

       

       

      If DOB in request = 2014-01-01, then the non eligible response would be:

       

      <NDS:status>0</NDS:status>

      <NDS:sessionID>D3236B42A5DCF03A</NDS:sessionID>

       

      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

       

      Jerry

       

       

       

       

       

       

      • nmrao's avatar
        nmrao
        Champion Level 3

        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.