mercredi 31 octobre 2018

Assertions for REST-ASSURED test

What I'm trying to do is create assertions on REST-ASSURED test.

I investigate that: "pointSum" actual match 0.45 so I tried:

.body("pointSum", hasItems(0.45)) with fail as: Expected: (a collection containing <0.45>) Actual: 0.45
.body("pointSum", is(0.45))       with fail as: Expected: is <0.45> Actual: 0.45
.body("pointSum", equalTo(0.45))  with fail as: Expected: <0.45> Actual: 0.45

And similar I investigate that: "topics.point" actual match [0.45] and I tried:

.body("topics.point", hasItems(0.45)) with fail as: Expected: (a collection containing <0.45>) Actual: [0.45]
.body("topics.point", is(0.45))       with fail as: Expected: is <0.45> Actual: [0.45]
.body("topics.point", equalTo(0.45))  with fail as: Expected: <0.45> Actual: 0.45

My response looks like this:

{
    "dateRange": {
        "begin": "2016-09-01",
        "end": "2016-09-01"
    },
    "pointSum": 0.45,
    "topics": [
        {
            "name": "Test topic",
            "point": 0.45,
            "texts": [
                {
                    "name": "Test text",
                    "point": 0.45,
                    "authors": [
                        {
                            "name": "John",
                            "point": 0.18
                        },
                        {
                            "name": "Thomas",
                            "point": 0.22
                        }
                    ]
                }
            ]
        }
    ]
}

(I'm not sure if you need to know, but there can be more than one topic and more than one text, and more than one user)

Aucun commentaire:

Enregistrer un commentaire