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

JObject.Should().ContainSubtree() is hard to debug when it fails #31

Open
diaconesq opened this issue Nov 15, 2019 · 0 comments
Open

JObject.Should().ContainSubtree() is hard to debug when it fails #31

diaconesq opened this issue Nov 15, 2019 · 0 comments

Comments

@diaconesq
Copy link

diaconesq commented Nov 15, 2019

One of the most enticing promises of the FluentAssertions library is having descriptive error messages when the assertions fail.

.ContainSubtree() falls short in this respect. Here is an example message:

Message: Expected JSON document to contain subtree
   {  "backendMetadata": {    "cosmosDbPartitionKey": "B"  }} ,
but some elements were missing.

It doesn't really tell me what's wrong.
At the very least, it should print out the input json (if it has a reasonable size).
It would be better (but more work) for the message to pinpoint the error ("some elements were missing" -- which ones?)

In the above case, the input is not really missing any elements, it's the innermost value that has a different value.

Here's a quick repro:

            JObject.Parse(      @" { backendMetadata: { cosmosDbPartitionKey: 'A' } } ")
                .Should()
                .ContainSubtree(@" { backendMetadata: { cosmosDbPartitionKey: 'B' } } ");

#6

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

No branches or pull requests

2 participants