Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected output using with on a map #252

Open
dump247 opened this issue Dec 10, 2021 · 0 comments · May be fixed by #298
Open

Unexpected output using with on a map #252

dump247 opened this issue Dec 10, 2021 · 0 comments · May be fixed by #298

Comments

@dump247
Copy link
Contributor

dump247 commented Dec 10, 2021

Given this example

class Foo {
    val bar: Map<String, Any?> = mapOf("biz" to mapOf("a" to 1))
}

@Test
fun x() {
    expectThat(Foo()) {
        with({ bar }) {
            getValue("biz").isA<Map<String, Int>>().and {
                hasEntry("a", 2)
            }
        }
    }
}

The test produces the following output

▼ Expect that Foo@133aca79:
  ▼ hasEntry("a", 2):
    ✓ has an entry with the key "biz"
    ▼ entry ["biz"]:
      ✓ is an instance of java.util.Map
      ✓ has an entry with the key "a"
      ▼ entry ["a"]:
        ✗ is equal to 2
                found 1

The expected output is

▼ Expect that Foo@133aca79:
  ▼ bar:
    ✓ has an entry with the key "biz"
    ▼ entry ["biz"]:
      ✓ is an instance of java.util.Map
      ✓ has an entry with the key "a"
      ▼ entry ["a"]:
        ✗ is equal to 2
                found 1

strikt 0.32.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant