jetCheck: update doc, make API more permissive

This commit is contained in:
peter
2018-02-21 14:35:43 +01:00
parent c0c9e96387
commit c27efdd2a8
2 changed files with 8 additions and 4 deletions
@@ -101,7 +101,7 @@ public interface ImperativeCommand {
* @param command a supplier for a top-level command. This supplier should not have any side effects.
* @see #checkScenarios
*/
static Generator<Scenario> scenarios(@NotNull Supplier<ImperativeCommand> command) {
static Generator<Scenario> scenarios(@NotNull Supplier<? extends ImperativeCommand> command) {
return Generator.from(data -> new ScenarioImpl(command.get(), data));
}
@@ -109,16 +109,19 @@ public interface ImperativeCommand {
* Performs a check that the scenarios generated by the given command are successful. Default {@link PropertyChecker} settings are used.
* @param command a supplier for a top-level command. This supplier should not have any side effects.
*/
static void checkScenarios(@NotNull Supplier<ImperativeCommand> command) {
static void checkScenarios(@NotNull Supplier<? extends ImperativeCommand> command) {
PropertyChecker.forAll(scenarios(command)).shouldHold(Scenario::ensureSuccessful);
}
/**
* An analog of {@link PropertyChecker#recheckingIteration} in the imperative command world.
* Performs a check that the scenario generated by the given command with given seed/sizeHint parameter is successful.
* Performs a check that the scenario generated by the given command is successful with given data (as serialized and printed by {@link PropertyFalsified} exception).
* @param command a supplier for a top-level command. This supplier should not have any side effects.
* @deprecated To catch your attention. It's fine to call this method during test debugging, but it should not be committed to version control
* and used in regression tests, because any changes in the test itself or the framework can render the passed data obsolete.
* For regression testing, it's recommended to code the failing scenario explicitly.
*/
static void checkScenario(@NotNull String serializedData, @NotNull Supplier<ImperativeCommand> command) {
static void checkScenario(@NotNull String serializedData, @NotNull Supplier<? extends ImperativeCommand> command) {
//noinspection deprecation
PropertyChecker.forAll(scenarios(command)).rechecking(serializedData).shouldHold(Scenario::ensureSuccessful);
}
@@ -83,6 +83,7 @@ public class StatefulGeneratorTest extends PropertyCheckerTestCase {
PropertyFailure<?> failure = e.getFailure();
try {
//noinspection deprecation
ImperativeCommand.checkScenario(failure.getMinimalCounterexample().getSerializedData(), command);
fail();
}