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

Conversions for typeCompatibleWith produce incorrect assertions #6

Open
hakanai opened this issue Mar 29, 2022 · 1 comment
Open

Conversions for typeCompatibleWith produce incorrect assertions #6

hakanai opened this issue Mar 29, 2022 · 1 comment

Comments

@hakanai
Copy link

hakanai commented Mar 29, 2022

Currently, these:

assertThat(x, is(typeCompatibleWith(Y.class)));
assertThat(x, is(not(typeCompatibleWith(Y.class))));

Are replaced by these:

assertThat(x).isInstanceOf(Y.class);
assertThat(x).isAssignableFrom(Y.class);

But both of these are wrong.

Hamcrest's typeCompatibleWith is equivalent to a reverse isAssignableFrom check, and AssertJ appears to have no equivalent at present (currently v3.22.0).

Really, it seems like AssertJ wants an isAssignableTo / isNotAssignableTo pair.

This was seemingly requested but they ended up implementing only hasSuperclass which only checks the immediate superclass. :(

@hakanai
Copy link
Author

hakanai commented Mar 29, 2022

I couldn't find an existing ticket over in AssertJ so I also filed assertj-core #2545.

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