Java Code Examples for org.mockito.Mockito#validateMockitoUsage()

The following examples show how to use org.mockito.Mockito#validateMockitoUsage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidUnitTest.java    From AndroidUnitTest with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            MockitoAnnotations.initMocks(target);
            androidUnitTestAnnotations.init(target);
            base.evaluate();
            Mockito.validateMockitoUsage();
        }
    };
}
 
Example 2
Source File: ExplicitFrameworkValidationTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldDetectMisplacedArgumentMatcher() {
    anyObject();
    try {
        Mockito.validateMockitoUsage();
        fail();
    } catch (InvalidUseOfMatchersException e) {}
}
 
Example 3
Source File: ExplicitFrameworkValidationTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldDetectUnfinishedStubbing() {
    when(mock.simpleMethod());
    try {
        Mockito.validateMockitoUsage();
        fail();
    } catch (UnfinishedStubbingException e) {}
}
 
Example 4
Source File: DaggerMockRule.java    From DaggerMock with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            MockitoAnnotations.initMocks(target);

            setupComponent(target);

            base.evaluate();

            Mockito.validateMockitoUsage();
        }
    };
}
 
Example 5
Source File: ExplicitFrameworkValidationTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldValidateExplicitly() {
    verify(mock);
    try {
        Mockito.validateMockitoUsage();
        fail();
    } catch (UnfinishedVerificationException e) {}
}
 
Example 6
Source File: MockitoAfterTestNGMethod.java    From mockito-cookbook with Apache License 2.0 5 votes vote down vote up
public void applyFor(IInvokedMethod method, ITestResult testResult) {
    Mockito.validateMockitoUsage();

    if (method.isTestMethod()) {
        resetMocks(testResult.getInstance());
    }
}
 
Example 7
Source File: FrameworkUsageValidator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void testFinished(Description description) throws Exception {
    super.testFinished(description);
    try {
        Mockito.validateMockitoUsage();
    } catch(Throwable t) {
        notifier.fireTestFailure(new Failure(description, t));
    }
}
 
Example 8
Source File: MockitoTestRule.java    From firebase-admin-java with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      MockitoAnnotations.initMocks(target);
      try {
        base.evaluate();
      } finally {
        Mockito.validateMockitoUsage();
      }
    }
  };
}
 
Example 9
Source File: ExplicitFrameworkValidationTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldDetectUnfinishedStubbing() {
    when(mock.simpleMethod());
    try {
        Mockito.validateMockitoUsage();
        fail();
    } catch (UnfinishedStubbingException e) {}
}
 
Example 10
Source File: ExplicitFrameworkValidationTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldDetectMisplacedArgumentMatcher() {
    anyObject();
    try {
        Mockito.validateMockitoUsage();
        fail();
    } catch (InvalidUseOfMatchersException e) {}
}
 
Example 11
Source File: MockitoAfterTestNGMethod.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void applyFor(IInvokedMethod method, ITestResult testResult) {
    Mockito.validateMockitoUsage();

    if (method.isTestMethod()) {
        resetMocks(testResult.getInstance());
    }
}
 
Example 12
Source File: FrameworkUsageValidator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void testFinished(Description description) throws Exception {
    super.testFinished(description);
    try {
        Mockito.validateMockitoUsage();
    } catch(Throwable t) {
        notifier.fireTestFailure(new Failure(description, t));
    }
}
 
Example 13
Source File: TextFormatFileTransportTest.java    From bazel with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  Mockito.validateMockitoUsage();
}
 
Example 14
Source File: JsonFormatFileTransportTest.java    From bazel with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  Mockito.validateMockitoUsage();
}
 
Example 15
Source File: BuildEventServiceGrpcClientTest.java    From bazel with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  Mockito.validateMockitoUsage();
}
 
Example 16
Source File: BinaryFormatFileTransportTest.java    From bazel with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  Mockito.validateMockitoUsage();
}
 
Example 17
Source File: SchedulerRestartServiceTest.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@After
public void afterTest() {
  Mockito.validateMockitoUsage();
}
 
Example 18
Source File: ServiceTest.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@After
public void afterTest() {
    Mockito.validateMockitoUsage();
}
 
Example 19
Source File: AsynchronousFileOutputStreamTest.java    From bazel with Apache License 2.0 4 votes vote down vote up
@After
public void validateMocks() {
  Mockito.validateMockitoUsage();
}
 
Example 20
Source File: DaggerMockRule.java    From DaggerMock with Apache License 2.0 3 votes vote down vote up
public void initMocks(Object target) {
    MockitoAnnotations.initMocks(target);

    setupComponent(target);

    Mockito.validateMockitoUsage();
}