All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockito.junit.MockitoRule Maven / Gradle / Ivy

There is a newer version: 2.0.2-beta
Show newest version
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