Class ParallelMatcher<T>

java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeDiagnosingMatcher<T>
org.dmfs.jems2.hamcrest.matchers.ParallelMatcher<T>
All Implemented Interfaces:
org.hamcrest.Matcher<T>, org.hamcrest.SelfDescribing

public final class ParallelMatcher<T> extends org.hamcrest.TypeSafeDiagnosingMatcher<T>
A Matcher which runs another matcher multiple times in concurrent threads. This can help in finding potential race conditions and other concurrency issues. However, due to the nature of such issues there is no guarantee that all, if any, existing issues will be reported. So take the results with a grain of salt.

Note, when running time consuming tests make sure you reduce the number of threads to ensure the test will terminate in a timely manner.

Also note, due to the way hamcrest matchers work and the nature of concurrency issues, this test can not report the mismatch description of a failing matcher.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ParallelMatcher(int threads, org.hamcrest.Matcher<T> delegate)
     
    ParallelMatcher(org.hamcrest.Matcher<T> delegate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    describeTo(org.hamcrest.Description description)
     
    protected boolean
    matchesSafely(T item, org.hamcrest.Description mismatchDescription)
     
    static <T> org.hamcrest.Matcher<T>
    parallel(int threads, org.hamcrest.Matcher<T> delegate)
     
    static <T> org.hamcrest.Matcher<T>
    parallel(org.hamcrest.Matcher<T> delegate)
     

    Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher

    describeMismatch, matches

    Methods inherited from class org.hamcrest.BaseMatcher

    _dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ParallelMatcher

      public ParallelMatcher(org.hamcrest.Matcher<T> delegate)
    • ParallelMatcher

      public ParallelMatcher(int threads, org.hamcrest.Matcher<T> delegate)
  • Method Details

    • parallel

      public static <T> org.hamcrest.Matcher<T> parallel(int threads, org.hamcrest.Matcher<T> delegate)
    • parallel

      public static <T> org.hamcrest.Matcher<T> parallel(org.hamcrest.Matcher<T> delegate)
    • matchesSafely

      protected boolean matchesSafely(T item, org.hamcrest.Description mismatchDescription)
      Specified by:
      matchesSafely in class org.hamcrest.TypeSafeDiagnosingMatcher<T>
    • describeTo

      public void describeTo(org.hamcrest.Description description)