You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From issue 344 in the old issue tracker at Google Code:
Given a tested class with a single public constructor having several parameters of distinct types, and an @Injectable field in the test class for each parameter, the following exception was reported to occur:
java.lang.IllegalArgumentException: No constructor in class com.murex.processing.plugins.ppsconnector.utility.UtilityServiceImpl that can be satisfied by available injectables
I think it’s worth it for the code to take the time and include in the exception message at least:
which constructors it found (if there are several) and which of these it chose to use for injection;
which constructor arguments or injectable fields it could not satisfy;
for each element of (2), if there are any fields or parameters in scope that have a type assignable to that element (annotated or not), the reason why it was not selected;
ideally, it should also tell you why it matched the parts that it could match (mostly useful if there were several possibilities).
In other words, rather than:
java.lang.IllegalArgumentException: No constructor in class my.TestedClass that can be satisfied by available injectables
It should say something like this:
java.lang.IllegalArgumentException: No constructor in class my.TestedClass that can be satisfied by available injectables:
Candidate constructor my.TestedClass.TestedClass(A, B, C) cannot be satisfied:
Argument 1 cannot be satisfied: ) there are no fields of parameters of type A (or “assignable to A”, I’m not sure of the rules here)
Argument 2 cannot be satisfied:
*) candidate field my.TestedClassUnitTests.instanceA is not annotated with @Injectable
Argument 3 is satisfied by field my.TestedClassUnitTests.instanceC:
*) argument 2 of my.TestedClassUnitTests.testSomething(C, C) matches but / reason this was not preferred /
*) field my.TestedClassUnitTests.instanceC2 / idem */
Candidate constructor my.TestedClass.TestedClass(A, D) cannot be satisfied:
Argument 1 cannot be satisfied (see above)
Argument 2 cannot be satisfied /* whatever reason */
The text was updated successfully, but these errors were encountered:
From issue 344 in the old issue tracker at Google Code:
Given a tested class with a single public constructor having several parameters of distinct types, and an @Injectable field in the test class for each parameter, the following exception was reported to occur:
java.lang.IllegalArgumentException: No constructor in class com.murex.processing.plugins.ppsconnector.utility.UtilityServiceImpl that can be satisfied by available injectables
I think it’s worth it for the code to take the time and include in the exception message at least:
In other words, rather than:
java.lang.IllegalArgumentException: No constructor in class my.TestedClass that can be satisfied by available injectables
It should say something like this:
java.lang.IllegalArgumentException: No constructor in class my.TestedClass that can be satisfied by available injectables:
Candidate constructor my.TestedClass.TestedClass(A, B, C) cannot be satisfied:
Argument 1 cannot be satisfied:
) there are no fields of parameters of type A (or “assignable to A”, I’m not sure of the rules here)
Argument 2 cannot be satisfied:
*) candidate field my.TestedClassUnitTests.instanceA is not annotated with @Injectable
Argument 3 is satisfied by field my.TestedClassUnitTests.instanceC:
*) argument 2 of my.TestedClassUnitTests.testSomething(C, C) matches but / reason this was not preferred /
*) field my.TestedClassUnitTests.instanceC2 / idem */
Candidate constructor my.TestedClass.TestedClass(A, D) cannot be satisfied:
Argument 1 cannot be satisfied (see above)
Argument 2 cannot be satisfied /* whatever reason */
The text was updated successfully, but these errors were encountered: