org.mockito.junit.MockitoRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-all Show documentation
Show all versions of mockito-all Show documentation
Mock objects library for java
package org.mockito.junit;
import org.junit.rules.MethodRule;
/**
* The JUnit rule can be used instead of {@link org.mockito.runners.MockitoJUnitRunner}.
* It requires JUnit at least 4.7.
*
* This rule adds following behavior:
*
* -
* Initializes mocks annotated with {@link org.mockito.Mock},
* so that explicit usage of {@link org.mockito.MockitoAnnotations#initMocks(Object)} is not necessary.
* Mocks are initialized before each test method.
*
-
* validates framework usage after each test method. See javadoc for {@link org.mockito.Mockito#validateMockitoUsage()}.
*
* Example use:
*
* public class ExampleTest {
*
* @Rule
* public MockitoRule rule = MockitoJUnit.rule();
*
* @Mock
* private List list;
*
* @Test
* public void shouldDoSomething() {
* list.add(100);
* }
* }
*
*
* @since 1.10.17
*/
public interface MockitoRule extends MethodRule {}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy