@Test public void zeroRatioStopsAfterDiscardsExceedSampleSize() { assertThat( testResult(ZeroDiscardRatio.class), hasFailureContaining(GenerationContext.DiscardRatioExceededException.class.getName())); assertEquals(0, ZeroDiscardRatio.iterations); }
@Theory public void shouldHold(@ForAll Callable<Integer> c) throws Exception { ++iterations; Integer value = functionValue(new IntegerGenerator(), null); for (int i = 0; i < 10000; ++i) assertEquals(value, c.call()); }
@Test public void willStopGeneratingValuesAfterDiscardRatioExceeded() { assertThat( testResult(ExceededDiscardRatio.class), hasFailureContaining(GenerationContext.DiscardRatioExceededException.class.getName())); assertEquals(0, ExceededDiscardRatio.iterations); }
@Theory public void shouldHold(@ForAll @From(Ctor.class) P p) { assertTrue(p.box().marked()); assertTrue(p.box().contents().marked()); assertEquals(2, p.box().contents().i()); }
@Test public void callable() throws Exception { assertThat(testResult(CallableOfInt.class), isSuccessful()); assertEquals(defaultSampleSize(), CallableOfInt.iterations); }
@Test public void shouldBeAbleToMarkMultipleParametersForReceivingValues() { assertThat(testResult(ForValuesOfMultipleParameters.class), isSuccessful()); assertEquals(21, ForValuesOfMultipleParameters.iterations); }
@Test public void shouldRespectSampleSizeIfSpecified() { assertThat(testResult(ForSpecifiedNumberOfValues.class), isSuccessful()); assertEquals(5, ForSpecifiedNumberOfValues.iterations); }
@Test public void shouldFeedADefaultNumberOfValuesToAMarkedParameter() throws Exception { assertThat(testResult(ForDefaultNumberOfValues.class), isSuccessful()); assertEquals(defaultSampleSize(), ForDefaultNumberOfValues.iterations); }
@Test public void negativeRatioWillNeverGenerateValues() { assertThat( testResult(NegativeDiscardRatio.class), hasFailureContaining("Never found parameters")); assertEquals(0, NegativeDiscardRatio.iterations); }
@Test public void okIfParameterMarkedWithUnexpectedConfiguration() { assertThat(testResult(WithSpuriousConfiguration.class), isSuccessful()); assertEquals( Formatter.BigDecimalLayoutForm.values().length, WithSpuriousConfiguration.iterations); }