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

Better error message for type mismatch in test-utils' argument assertions #876

Open
ash211 opened this issue Aug 2, 2022 · 0 comments
Open

Comments

@ash211
Copy link
Contributor

ash211 commented Aug 2, 2022

What happened?

I recently got this error message:

java.lang.AssertionError: Expected unsafe args to be {extra=[extra], missing=[missing_secret, missing_secret2]}, but found {extra=[extra], missing=[missing_secret, missing_secret_2]}

which is confusing because it looks like expected and actual are the same. Actually, their types are different -- one is a String "[extra]" and one is a Set ImmutableSet.of("extra").

In the case where two objects are different, but their toStrings() are equal, we should additionally show in the error message the types of the two objects.

This would happen here:

Minimal repo:

        assertThatServiceExceptionThrownBy(() -> {
                    throw new ServiceException(ErrorType.INTERNAL, UnsafeArg.of("list", ImmutableList.of("a")));
                })
                .hasArgs(UnsafeArg.of("list", "[a]"));

currently gives message:

java.lang.AssertionError: Expected unsafe args to be {list=[a]}, but found {list=[a]}

What did you want to happen?

Should return a message like:

java.lang.AssertionError: Expected unsafe args to be {list=[a]} with value type String, but found {list=[a]} with value type ImmutableList<String>

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

No branches or pull requests

1 participant