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

com.fitbur.mockito.junit.MockitoRule Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.mockito.junit;

import org.junit.rules.MethodRule;

/**
 * The JUnit rule can be used instead of {@link com.fitbur.mockito.runners.MockitoJUnitRunner}.
 * It requires JUnit at least 4.7.
 *
 * This rule adds following behavior:
 * 
    *
  • * Initializes mocks annotated with {@link com.fitbur.mockito.Mock}, * so that explicit usage of {@link com.fitbur.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 com.fitbur.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 - 2024 Weber Informatics LLC | Privacy Policy