authorjapps/zerocode

Assertions using json schema v3 or v4

Open

#126 aperta il 6 set 2018

Vedi su GitHub
 (9 commenti) (1 reazione) (1 assegnatario)Java (447 fork)auto 404
good first issuelow-priority

Metriche repository

Star
 (1010 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

AC1: GIVEN-The JSON schema of the API response WHEN-I assert the API response using the schema with version as parameter THEN-I should be able to get the desired result as PASS or FAIL to determine the test status. AND-If failed, it should display or log(WARN or ERROR level) list the failure reasons in a pretty format.

AC2: Have mechanism to pass the Schema file for the API response in the DSL.

Note: "responseSchema" : (* new field which you can introduce) : Keep it optional. If supplied by the user, only then validate against it(the "body" of the response).

I think only the "body" should match the Schema definition, right? Definitely not the "status" I mean. Have a look at the Schema definition file. If yes, then implement the field as "responseBodySchema" (instead of "responseSchema")

Example:

{
    ...
    ...
    "responseSchema": {
        "schemaPath": "path/to/schema/file",
        "schemaVersion": "W3 Version? 3.0 or 4.0" //<--- optional (assign a default value if not supplied by user)
    },
    "verify": {
        "status": 200,
        "body": {
            "login": "octocat",
            "id": 583231,
            "type": "User"
        }
    }
}

AC3: (Future purpose - Implement via a new ticket if there is a Usecase for this, otherwise not needed now as AC2 shd cover most usecases) GIVEN-I want to assert the API response using a given schema of v3 or v4(parameterised) WHEN-I receive the API response THEN-I should be able to get the desired result as PASS or FAIL to determine the test status

Guida contributor