New reflection API Still lacks several Features of old reflection API #130
Labels
help wanted
Extra attention is needed
invalid
This doesn't seem right
priority: high
An issue with high priority
Why we shouldn't ditch the old Reflection API just yet
The Problem
The new Reflection API was build from the Ground using better Patterns and being much more versatile in it's application. At least in theory. In #74 we deprecated the reflection API stating that the new API is ready to replace it. However after using the new reflect API for a more complex Assignment where Students have to declare their own Classes, i realize it's still very much incomplete.
new vs old API
Here is a comprehensive List of things that are currently missing in the new API but are present in the old API. Until all of these are ported to the new API, we should imo not remove or deprecate the old one.
methodLink.verify(mock,times(5)
)methodLink.when(mock,<Answer>)
).resolve()
, currently needs hacky workaround using sth likeSuppliers.memoize()
from Guava)typeLink.setField(obj)
andtypeLink.setFieldTyped(obj,clazz)
new ClassTester(clazz).resolveInstance(param1,...)
which first tried to create an instance by using the constructor, then as a fallback returned a mock. With the new API you have totl
By callingBasicTypeLink.of(clazz);
cl
by callingAssertions3.assertConstructorExists(tl,BasicReflectionMatchers.sameTypes(args));
(for args you then have to create a Type link for every arg again...)What now?
I think i will still use parts of the old API for my personal Tests until the new one is matured. However i really prefer the new structure as it has a lot more potential. So porting the old functions over should be one of our top priorities this year as i started in #129.
The text was updated successfully, but these errors were encountered: