How do you put Mock object in the Mock object?
-
I'm getting a layer service, and I have a DAO slope, how to moculate the dao layer, which in turn I want to inject into a layer that will also be sealed?
I don't understand. I have this code in my test.
@Mock private NewsService mockNewsService;
@Mock
private CommentService mockCommentService;@Mock
private TagService mockTagService;@Mock
private AuthorService mockAuthorService;@InjectMocks
@Autowired
private TransactionManagement transactionManagement;
and all appropriate beans in xml are identified.
I don't understand why DAO works?
So my service as IOC doesn't work, it goes further, to Dao, why could it be?
I'm finally making a big mistake in the Dao that I'm giving the meaning of zero.
So if you just lock up the service isn't enough?
Yes, you do.
'cause I have a service that causes a dao layer.
-
Let's say the MyService class:
public class MyService { @Inject private MyDAO myDAO;
//остальной код
}
It's myDAO's test.
public class MyServiceTest {
@Mock private MyDAO mockDao; @InjectMocks private MyService service; @Before public void init() { MockitoAnnotations.initMocks(this); }
}
If MyService Mock himself, there's no point and opportunity to inject MyDAO.