Search in sources :

Example 1 with MatcherCheckerFn

use of org.apache.beam.sdk.testing.PAssert.MatcherCheckerFn in project beam by apache.

the class PAssertTest method testAssertionSiteIsCaptured.

@Test
public void testAssertionSiteIsCaptured() {
    // This check should return a failure.
    SuccessOrFailure res = PAssert.doChecks(PAssert.PAssertionSite.capture("Captured assertion message."), 10, new MatcherCheckerFn(SerializableMatchers.contains(11)));
    String stacktrace = Throwables.getStackTraceAsString(res.assertionError());
    assertFalse(res.isSuccess());
    assertThat(stacktrace, containsString("PAssertionSite.capture"));
}
Also used : MatcherCheckerFn(org.apache.beam.sdk.testing.PAssert.MatcherCheckerFn) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

MatcherCheckerFn (org.apache.beam.sdk.testing.PAssert.MatcherCheckerFn)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1