easyforgood / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

Inject mocks into existing object #449

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
suppose you have a class with mocks:

public class Something
{
   Mocked mocked;
}

public class ATest
{
    @Mock Mocked mocked;
    @Before public void setUp() throws Exception
    {
        MockitoAnnotations.initMocks(this);
    }
    @Test public void test() throws Exception
    {
        for(...)// this could be some factory method
        {
            Something s = new Something();
            // here I want inject "mocked" into "s"
        }
    }
}

What is the expected output? What do you see instead?
I expect a function which allows to inject available mocks into any instance, 
similar to 
http://google-guice.googlecode.com/git/javadoc/com/google/inject/Injector.html#i
njectMembers%28java.lang.Object%29 method

What version of the product are you using? On what operating system?
1.9.5

Original issue reported on code.google.com by kan....@gmail.com on 5 Sep 2013 at 9:50

GoogleCodeExporter commented 8 years ago
I don't know about this injection feature.

The code you mentioned is much more related to dependency injection framework, 
which Mockito is not. It merely minimize boilerplate injection code for simple 
cases.

I'll mark this issue as won't fix, but you still could make a PR on github and 
ask people if they really want it.

Original comment by brice.du...@gmail.com on 4 Dec 2013 at 1:49