Skip to content

Equals assert #15

Description

@giovannicandido

Assert field by field is annoying and sometimes we want to compare the whole result.

Something like

val request = ChargeRequest(listOf(ItemRequest(1, "test", 1)), MetadataRequest("0001", ""))
val exectedJson = """
      {"metadataRequest":{"custom_id":"0001", "notification_url":""},"items":[{"amount":1,"name":"test","value":1}]}
    """.trimIndent()

JSONAssert.assertEquals(request.toJsonString, exectedJson, true)

In JSONAssert, there is the strict configuration. When true all fields must be equal and have the same property count. When false the fields that exist on the expectations must match, but extra fields are allowed.
For example:

object a:

{
"foo":  "bar",
"bar": "foo"
}

object b:

{
"foo":  "bar"
}

In strict mode: a != b
Strict mode false: a = b

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions