com.atlassian.jira.junit.rules
Class MockitoMocksInContainer
java.lang.Object
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.
Usage:
@Rule public RuleChain mocksInContainer = MockitoMocksInContainer.forTest(this);
@Mock
@AvailableInContainer
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
- Since:
- v5.2
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 |
forTest
public static org.junit.rules.RuleChain forTest(Object test)
Copyright © 2002-2013 Atlassian. All Rights Reserved.