Forum Discussion

rg2018's avatar
rg2018
Occasional Contributor
6 years ago
Solved

Script Assertion each statement

I'm trying to assert 0 position in file with my expected results. Within the log expected[0] appears to = filtered[0] which is the filtered parsed json file.  When I do an assert within each statemen...
  • Radford's avatar
    Radford
    6 years ago

    This is just a guess from looking at you post above, where you define your expected results (I've reformatted for clarity):

     

    def expectedResults = [
                           [
                            criteriaName: "Impact_On_Functioning", 
                            levelOfCareName: "Hospital_Level_of_Care", 
                            outcome: "Met", 
                            parentCriteria: "null", 
                            parentCriteriaName: "null", 
                            programName: "Hospital_Level_of_Care"
                           ]
                          ]

    I see that you are representing your null values as the string "null" which is different to a true null value. But when logged out would look the same. Try changing your expected reply to:

     

     

    def expectedResults = [
                           [
                            criteriaName: "Impact_On_Functioning", 
                            levelOfCareName: "Hospital_Level_of_Care", 
                            outcome: "Met", 
                            parentCriteria: null, 
                            parentCriteriaName: null, 
                            programName: "Hospital_Level_of_Care"
                           ]
                          ]

     

    Note: How I've dropped the quotes around the two null values.

     

    As I mentioned this is just a guess but could be worth a try.