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
Support constructor injection when using Spring with @Qualifier #290
Comments
@qualifier is already supported, but Spring's @Service/@Repository/@Component/@Controller/@primary is not. However, I believe a better solution will be to improve the support for @tested object reuse. With that, the test class would be written as:
... where the "commonDependency" tested object would be reused for the dependency in the other tested object. This already works, provided other classes implementing the interface haven't been loaded yet. |
Thanks, that sounds good. It is not always possible to control which implementation classes will be loaded before the test execution: It would be helpful, if the preferred implementation class could optionally be set via an attribute in the annotation. Example:
|
You will be able to use the implementation class (Dependency) as the type for the @tested field, so this "preferredClass" attribute won't be necessary. |
That is even better, as it is much more intuitive. |
Many thanks for the implementation of this great enhancement. |
Support constructor injection when using Spring with @qualifier. Real (unmocked) instance of the type which corresponds to the chosen qualifier, should satisfy the constructor of the tested class.
Currently this test fails:
The following exception is thrown:
The text was updated successfully, but these errors were encountered: