Class MockitoMocksInContainer

  extended by com.atlassian.jira.junit.rules.MockitoMocksInContainer

public class MockitoMocksInContainer
extends Object

Factory for a rule that combines mockito initialization with MockComponentContainer. This will take care of initializing mocks using Mockito and also putting them in a mock component container so that they're available via ComponentAccessor.getComponent(Class). After the test has run, the mock container will be tear down so that next test does not accidentally access stale state.


     @Rule public RuleChain mocksInContainer = MockitoMocksInContainer.forTest(this);

     private UserService mockUserService;

     @Mock private JiraAuthenticationContext jiraAuthenticationContext;
where the userService will be available via ComponentAccessor, but the jiraAuthenticationContext will just be instantiated as a Mockito mock


Method Summary
static org.junit.rules.RuleChain forTest(Object test)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail


public static org.junit.rules.RuleChain forTest(Object test)

Copyright © 2002-2013 Atlassian. All Rights Reserved.