Open joolurik opened 1 year ago
Hi joolurik,
sounds quite interesting! DeepSampler has an abstraction layer for AOP, so it should be independent of concrete AOP frameworks. We designed DeepSampler this way to be able to do exactly what you are suggesting!
We have an abstract concept, that we like to call aop-provider
. In fact, this is the starting point of DeepSampler, you could see it as the main()
-method of DeepSampler.
An aop-provider
lives inside of a particular aop-framework. It's job is to intercept method-calls and to send these method-calls to DeepSampler. The way, how this is done, is completely open to the authors of aop-providers.
An example can be found in GuiceSamplerAspect.java and another one in SpringSamplerAspect.java, I suggest to start with the guice-version because it is much simpler than Spring.
So, the interesting part of that project would be to find a way to integrate something that is able to intercept method-calls in Dagger. One solution that I can think of might be AspectJ with compile-time-weaving. In fact, this might even be a generalized solution that could work nearly everywhere, independent of any dependecy-injection-framework. We were thinking of writing this, but haven´t found the time yet.
A quick google search showed this: custom-annotation-interceptor-using-dagger-2 on StackOverflow. This might also be something to look into.
You could create a module (using maven or gradle) deepsampler-provider-dagger
that lives in your own GitHub repo. It would have the same dependencies to DeepSampler as deepsampler-provider-guice. You could publish this module to maven-central, so that others can use it together with DeepSampler.
Since a test-framework is meant to ensure the quality of the test-objects, it's quite important to thoroughly test the test-framework itself. We have two abstract Junit-test-classes that can be used to test all aop-providers and to ensure that all providers support the same functionality. But it would be great if you could add some additional tests, that we maybe didn't think of.
Hello,
I am looking to enable similar mocking for Dagger based dependency injection systems. I know dagger doesn't support AOP but want to quickly check here for extending this framework for Dagger.
FYI, Dagger is a compile time dependency injection framework and is getting popular in the recent times. https://medium.com/bigeye/dependency-injection-103-guice-vs-dagger-6ab7afa68d3d
Thanks,