Search in sources :

Example 1 with VerificationCollector

use of org.mockito.junit.VerificationCollector in project mockito by mockito.

the class VerificationCollectorImplTest method should_collect_multiple_verification_failures.

@Test
public void should_collect_multiple_verification_failures() {
    VerificationCollector collector = MockitoJUnit.collector().assertLazily();
    IMethods methods = mock(IMethods.class);
    verify(methods).simpleMethod();
    verify(methods).byteReturningMethod();
    try {
        collector.collectAndReport();
        fail();
    } catch (MockitoAssertionError error) {
        assertThat(error).hasMessageContaining("1. Wanted but not invoked:");
        assertThat(error).hasMessageContaining("2. Wanted but not invoked:");
    }
}
Also used : VerificationCollector(org.mockito.junit.VerificationCollector) MockitoAssertionError(org.mockito.exceptions.base.MockitoAssertionError) IMethods(org.mockitousage.IMethods) Test(org.junit.Test)

Example 2 with VerificationCollector

use of org.mockito.junit.VerificationCollector in project mockito by mockito.

the class VerificationCollectorImplTest method should_collect_verification_failures.

@Test(expected = MockitoAssertionError.class)
public void should_collect_verification_failures() {
    VerificationCollector collector = MockitoJUnit.collector().assertLazily();
    IMethods methods = mock(IMethods.class);
    verify(methods).simpleMethod();
    collector.collectAndReport();
}
Also used : VerificationCollector(org.mockito.junit.VerificationCollector) IMethods(org.mockitousage.IMethods) Test(org.junit.Test)

Example 3 with VerificationCollector

use of org.mockito.junit.VerificationCollector in project mockito by mockito.

the class VerificationCollectorImplTest method should_continue_collecting_after_failing_verification.

@Test
public void should_continue_collecting_after_failing_verification() {
    VerificationCollector collector = MockitoJUnit.collector().assertLazily();
    IMethods methods = mock(IMethods.class);
    methods.simpleMethod();
    verify(methods).byteReturningMethod();
    verify(methods).simpleMethod();
    this.assertAtLeastOneFailure(collector);
}
Also used : VerificationCollector(org.mockito.junit.VerificationCollector) IMethods(org.mockitousage.IMethods) Test(org.junit.Test)

Example 4 with VerificationCollector

use of org.mockito.junit.VerificationCollector in project mockito by mockito.

the class VerificationCollectorImplTest method should_only_collect_failures_ignore_succesful_verifications.

@Test
public void should_only_collect_failures_ignore_succesful_verifications() {
    VerificationCollector collector = MockitoJUnit.collector().assertLazily();
    IMethods methods = mock(IMethods.class);
    verify(methods, never()).simpleMethod();
    verify(methods).byteReturningMethod();
    this.assertAtLeastOneFailure(collector);
}
Also used : VerificationCollector(org.mockito.junit.VerificationCollector) IMethods(org.mockitousage.IMethods) Test(org.junit.Test)

Example 5 with VerificationCollector

use of org.mockito.junit.VerificationCollector in project mockito by mockito.

the class VerificationCollectorImplTest method should_not_throw_any_exceptions_when_verifications_are_succesful.

@Test
public void should_not_throw_any_exceptions_when_verifications_are_succesful() {
    VerificationCollector collector = MockitoJUnit.collector().assertLazily();
    IMethods methods = mock(IMethods.class);
    methods.simpleMethod();
    verify(methods).simpleMethod();
    collector.collectAndReport();
}
Also used : VerificationCollector(org.mockito.junit.VerificationCollector) IMethods(org.mockitousage.IMethods) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 VerificationCollector (org.mockito.junit.VerificationCollector)5 IMethods (org.mockitousage.IMethods)5 MockitoAssertionError (org.mockito.exceptions.base.MockitoAssertionError)1