-
Notifications
You must be signed in to change notification settings - Fork 31
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
Unable to modify AnnotatedType within test class #156
Comments
Hi Yes, I think the backed test class wasn't used in the actual test (i.e. the test instance you operate on was provided by junit); if memory serves, it was used to pick up producers and such. |
Just had a look and looks like it would be a pretty large rewrite. That's because it needs the test class instance to extract the |
@dansiviter yes, that's the catch indeed. I think this would be possible if we enforce that OFC this would be a massive breaking change for any tests using |
BTW this is similar to the discussion that took place in #144 One notable thing we didn't mention here is that not all test classes can be beans per specification - apart from no-arg constructor, inner classes cannot become beans. |
I think the scope of these changes would be too breaking for current versions but we could do them for next major version (targeting future Weld/CDI release). To implement the behavior you are looking for, you could also perform the injection manually. You can basically hook into any junit5 phase where you have the test instance object at your disposal and perform it there. Granted, it's not the best approach but the only I can think of without causing braking changes in Weld extension |
FTR, I have tried to rewrite Weld extension to support this (i.e. to provide test instances) and captured my findings in the following issues - #233 Thoughts and comments are welcome :) |
When trying to make an extension that auto injected mocks, I've ran into an issue where the test class cannot be modified through
ProcessAnnotatedType
extension event. I've created a test that replicates the issue here. It seems the test framework creates both a backed and unbacked version ofMyTest
class and the added@Inject
annotation is lost. My intention is my just defining@Mock
a@Singleton
mock would be created and injected into the class, but it seems this isn't possible.The text was updated successfully, but these errors were encountered: