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-core Show documentation
Show all versions of mockito-core Show documentation
Mockito mock objects library core API and implementation
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()}.
*
-
* Since 2.*, on test failure, stubbing warnings are printed to System output. They might be useful for debugging.
*
* 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 - 2025 Weber Informatics LLC | Privacy Policy