TheoryRunner { SearchResult<T> runSearch(final Predicate<T> property) { final Core core = new Core(this.strategy); final Property<T> prop = new Property<>(property, this.precursorSource.map(this.precursorToValue)); return core.run(prop, clock); } TheoryRunner(final Strategy state, final Gen<P> source, Function<P, T> f,
      AsString<T> toString, LongSupplier clock); static TheoryRunner<P,T> runner(final Strategy state,
          final Gen<P> source, Function<P, T> f, AsString<T> toString); static TheoryRunner<T, T> runner(final Strategy state,
      final Gen<T> source); void check(final Predicate<T> property);  }
@Test public void shouldRunAllExamplesWhenWithinWithinBoundingTime() { strategy = strategy .withTestingTime(10, TimeUnit.MILLISECONDS) .withExamples(5); when(clock.getAsLong()).thenReturn(0L, 9L); testee = makeTesteeFor(arbitrary().pick(1,2,3,4,5,6,7,8,9,10)); SearchResult<Integer> actual = testee.runSearch(i -> true); assertThat(actual.getExecutedExamples()).isGreaterThan(3); }
@Test public void shouldStopRuningExamplesWhenExceedsBoundingTime() { strategy = strategy .withTestingTime(10, TimeUnit.MILLISECONDS) .withExamples(10); when(clock.getAsLong()).thenReturn(0L, 8L,9L, 11L); testee = makeTesteeFor(arbitrary().pick(1,2,3,4,5,6,7,8,9,10)); SearchResult<Integer> actual = testee.runSearch(i -> true); assertThat(actual.getExecutedExamples()).isEqualTo(3); }