MockitoComponentMockingRule
instead@Deprecated public abstract class AbstractMockingComponentTestCase<T> extends AbstractMockingTestCase
AbstractComponentTestCase
test class. To use this class, annotate your test class with
with MockingRequirement
, passing the implementation class you're testing.
Then in your test code, do a lookup of your component under test and you'll get a component instance which has all
its injected dependencies mocked automatically. For example:
@MockingRequirement(MyComponentImplementation.class)
public class MyComponentTest extends AbstractMockingComponentTestCase<MyComponent>
{
@Test
public void someTest() throws Exception
{
MyComponent myComponent = getMockedComponent();
...
}
...
}
Note that by default there are no component registered against the component manager except those mocked
automatically by the @MockingRequirement
annotation. This has 2 advantages:
ComponentList
annotation and if you really really
need to register all components (it takes time) then use AllComponents
.mockery
Constructor and Description |
---|
AbstractMockingComponentTestCase()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
MockingComponentManager |
getComponentManager()
Deprecated.
|
T |
getMockedComponent()
Deprecated.
|
T |
getMockedComponent(Class mockedComponentClass)
Deprecated.
|
org.slf4j.Logger |
getMockLogger()
Deprecated.
|
org.slf4j.Logger |
getMockLogger(Class<?> mockedComponentClass)
Deprecated.
|
void |
setUp()
Deprecated.
|
getMockery, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent
public AbstractMockingComponentTestCase()
public T getMockedComponent() throws org.xwiki.component.manager.ComponentLookupException
MockingRequirement
annotationorg.xwiki.component.manager.ComponentLookupException
public T getMockedComponent(Class mockedComponentClass) throws org.xwiki.component.manager.ComponentLookupException
mockedComponentClass
- the class of the mocked component to returnMockingRequirement
annotation that is of the passed class typeorg.xwiki.component.manager.ComponentLookupException
public org.slf4j.Logger getMockLogger(Class<?> mockedComponentClass) throws Exception
Exception
public org.slf4j.Logger getMockLogger() throws Exception
Exception
public MockingComponentManager getComponentManager() throws Exception
getComponentManager
in class AbstractMockingTestCase
Exception
- in case of errorsCopyright © 2004–2019 XWiki. All rights reserved.