public PropertyCheckResult check(Consumer<ReportEntry> publisher) { long effectiveSeed = configuration.getSeed() == Property.SEED_NOT_SET ? RNG.get().nextLong() : configuration.getSeed(); PropertyConfiguration effectiveConfiguration = configuration.withSeed(effectiveSeed); try { return createGenericProperty().check(effectiveConfiguration, publisher); } catch (CannotFindArbitraryException cannotFindArbitraryException) { return PropertyCheckResult.erroneous(effectiveConfiguration.getStereotype(), propertyName, 0, 0, effectiveConfiguration.getSeed(), Collections.emptyList(), cannotFindArbitraryException); } }
private TestExecutionResult executeMethod(Object testInstance, EngineExecutionListener listener) { try { Consumer<ReportEntry> reporter = (ReportEntry entry) -> listener.reportingEntryPublished(methodDescriptor, entry); PropertyCheckResult propertyExecutionResult = executeProperty(testInstance, reporter); TestExecutionResult testExecutionResult = createTestExecutionResult(propertyExecutionResult); return testExecutionResult; } catch (TestAbortedException e) { return aborted(e); } catch (Throwable t) { rethrowIfBlacklisted(t); return failed(t); } }
public static ReportEntry from(PropertyCheckResult checkResult) { Map<String, String> entries = new HashMap<>(); entries.put(SEED_REPORT_KEY, Long.toString(checkResult.randomSeed())); entries.put(TRIES_REPORT_KEY, Integer.toString(checkResult.countTries())); entries.put(CHECKS_REPORT_KEY, Integer.toString(checkResult.countChecks())); checkResult.sample().ifPresent(sample -> { if (!sample.isEmpty()) entries.put(SAMPLE_REPORT_KEY, JqwikStringSupport.displayString(sample)); }); checkResult.originalSample().ifPresent(sample -> { if (!sample.isEmpty()) entries.put(ORIGINAL_SAMPLE_REPORT_KEY, JqwikStringSupport.displayString(sample)); }); return ReportEntry.from(entries); }
@Override public void reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry) { addEvent(ExecutionEvent.reportingEntryPublished(testDescriptor, entry)); }
public static ExecutionEvent reportingEntryPublished( TestDescriptor testDescriptor, ReportEntry entry) { return new ExecutionEvent(REPORTING_ENTRY_PUBLISHED, testDescriptor, entry); }
private PropertyCheckResult executeProperty(Object testInstance, Consumer<ReportEntry> publisher) { CheckedProperty property = checkedPropertyFactory.fromDescriptor(methodDescriptor, testInstance); return property.check(publisher); }
public static ExecutionEvent reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry) { return new ExecutionEvent(REPORTING_ENTRY_PUBLISHED, testDescriptor, entry); }
@Override public void reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry reportEntry) { }
@Override public void reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry) { }