/** * Matches if the tests are all successful */ public static Matcher<PrintableResult> isSuccessful() { return failureCountIs(0); }
@Test public void manyParameters() throws Exception { assertThat(testResult(ManyParameters.class), isSuccessful()); assertEquals(10, ManyParameters.iterations); assertEquals( new HashSet<>(asList(-1, -2, -4)), new HashSet<>(ManyParameters.firstValues.subList(0, 3))); assertEquals( new HashSet<>(asList('r', 'y')), new HashSet<>(ManyParameters.secondValues.subList(0, 2))); }
@Test public void autoGenerationOnPrimitiveWrapperType() { PrintableResult result = testResult(AutoGenerationOnPrimitiveWrapperType.class); assertThat( result, hasSingleFailureContaining(ReflectionException.class.getName())); assertThat( result, hasSingleFailureContaining(InstantiationException.class.getName())); }
@Test public void github_212_failWithIllegalFormatSpecifierInMessage() { assertThat( testResult(Failing.class), hasFailureContaining("Failure with a %D in the text")); }
@Test public void primitiveShorts() throws Exception { assertThat(testResult(PrimitiveShorts.class), isSuccessful()); assertEquals(defaultPropertyTrialCount(), PrimitiveShorts.iterations); assertEquals( new HashSet<>(asList(Short.valueOf("9"), Short.valueOf("8"))), new HashSet<>(PrimitiveShorts.values.subList(0, 2))); }
@Test public void autoGenerationOnPrimitiveWrapperType() { PrintableResult result = testResult(WithAutoGenerationOnPrimitiveWrapperType.class); assertThat(result, hasSingleFailureContaining(ReflectionException.class.getName())); assertThat(result, hasSingleFailureContaining("single accessible constructor")); }
@Test public void negativeRatioWillNeverGenerateValues() { assertThat( testResult(NegativeDiscardRatio.class), hasFailureContaining(IllegalArgumentException.class.getName())); assertEquals(0, NegativeDiscardRatio.iterations); }
/** * Matches if the tests are all successful */ public static Matcher<PrintableResult> isSuccessful() { return failureCountIs(0); }
@Test public void wrapperShorts() throws Exception { assertThat(testResult(WrapperShorts.class), isSuccessful()); assertEquals(defaultPropertyTrialCount(), WrapperShorts.iterations); assertEquals( new HashSet<>(asList(Short.valueOf("-13"), Short.valueOf("-14"))), new HashSet<>(WrapperShorts.values.subList(0, 2))); }
@Test public void malformedMin() { assertThat( testResult(MalformedMinZonedDateTime.class), hasSingleFailureContaining(DateTimeParseException.class.getName())); }
@Test public void willStopGeneratingValuesAfterDiscardRatioExceeded() { assertThat( testResult(ExceededDiscardRatio.class), hasFailureContaining(DiscardRatioExceededException.class.getName())); assertEquals(0, ExceededDiscardRatio.iterations); }
public boolean matches(Object item) { return item.toString().contains(string) && failureCountIs(1).matches(item); }
@Test public void primitiveBytes() throws Exception { assertThat(testResult(PrimitiveBytes.class), isSuccessful()); assertEquals(2, PrimitiveBytes.iterations); assertEquals( new HashSet<>(asList(Byte.valueOf("12"), Byte.valueOf("-13"))), PrimitiveBytes.testCases); }
@Test public void backwardsRange() { assertThat( testResult(BackwardsRange.class), hasSingleFailureContaining(IllegalArgumentException.class.getName())); }
@Test public void zeroRatioStopsAfterDiscardsExceedSampleSize() { assertThat( testResult(DefaultDiscardRatio.class), hasFailureContaining(DiscardRatioExceededException.class.getName())); assertEquals(0, DefaultDiscardRatio.iterations); }
public boolean matches(Object item) { return item.toString().contains(string) && failureCountIs(1).matches(item); }
@Test public void wrapperBytes() throws Exception { assertThat(testResult(WrapperBytes.class), isSuccessful()); assertEquals(2, WrapperBytes.iterations); assertEquals( new HashSet<>(asList(Byte.valueOf("14"), Byte.valueOf("-15"))), WrapperBytes.testCases); }
@Test public void malformedMax() { assertThat( testResult(MalformedMaxOffsetDateTime.class), hasSingleFailureContaining(DateTimeParseException.class.getName())); }
/** * Matches if the tests are all successful */ public static Matcher<PrintableResult> isSuccessful() { return failureCountIs(0); }
@Test public void wrapperShorts() throws Exception { assertThat(testResult(WrapperShorts.class), isSuccessful()); assertEquals(2, WrapperShorts.iterations); assertEquals( new HashSet<>(asList(Short.valueOf("-13"), Short.valueOf("-14"))), WrapperShorts.testCases); }