I created a test class for abstract ClassA. But i encountered an error Missing @Injectable for field "ClassC" in ClassB.
I tried renaming one of the ClassC field names and it worked. But how can I fix this error without renaming field name of ClassC?
My codes below :
abstract ClassA extends ClassB {
@Inject
ClassC classC;
}
abstract ClassB {
@Inject
ClassC classC;
}
//---------------- Test class for ClassA*
@RunWith(JMockit.class)
ClassATest {
@Injectable
ClassC classC;
}
You can use Tested
annotion and set fullyInitialized = true
.
public final class ExampleIntegrationTest {
@Tested(fullyInitialized = true)
private ClassA classA;
@Mocked
private ClassC classC;
//testMethod
}