Replies: 3 comments 2 replies
-
|
+1 if we can do it smoothly, which is always a bit of challenge with generics |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Is Happy to look at your real project if it's publicly available on GitHub. Following your example, this should be possible: @Test
void pluginsHaveTheExpectedValue() {
Validator validator = factory.newValidator();
assertThat(validator)
.asInstanceof(type(PluggableValidator.class))
.satisfies(v -> assertThat(v.getPlugins())
.contains(...));
} |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
I'm closing the discussion given that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
At the moment, if I am writing a test that checks the type of an object, I still have to manually cast after the check to downcast to the type I want to use.
For example... suppose I am testing the following code:
...and my test is this:
Right now, I have to still explicitly cast after the instance check. What I'd probably expect though is for methods like
.isInstanceOf(Class<T>)to return a newObjectAssert<T>for generic object assertions, such that the following is valid:I'm not sure if this is likely to introduce other implications due to the restrictiveness of the compiler when handling generics. Aware that varying the returned assertion type is not going to be possible with this since you cannot overload generic signatures at compile time.
Beta Was this translation helpful? Give feedback.
All reactions