On 2013-02-16 11:42, Markus Karg wrote:
> I want to use constructor injection (inject B-mock into A), so I did (using
> Java 7)...
>
> public final class A {
> public A(B b);
> }
>
> interface B {
> }
>
> @RunWith(MockitoJunitRunner.class) public MyTest {
> @Mock B b;
> @InjectMocks A a;
> @Test ... {}
> }
>
> When I start JUni 4.10, Mockito 1.9.5 says that it cannot find the default
> constructor. This is correct, as I do not have one, and as I do not want
> Mockito to call it -- as I want to use constructor injection (hence need a
> non-default-constructor).
I suspected that final in class A could make some problems, but I'm
unable to reproduce this with Mockito 1.9.5, JUnit 4.10, OpenJDK 7.
Could you provide a complete test case with testing classes?
Marcin
>
> What to do?
>
> If I simply add the default constructor, Mockito calls that one, hence does
> not inject into the non-default constructor.
>
> I am totally desparate, please help! :-)
>
>
>
--
http://blog.solidsoft.info/ - Working code is not enough