From eed0650d80d99c42be7943b9a653e22c35c52ce5 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 5 Aug 2019 22:49:07 +0300 Subject: Add: three sketches for Fable acceptance tests There are no implementations yet, this is just to start sketching out what the scenarios for Fable itself should be. --- fable-arch.md | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 112 insertions(+), 8 deletions(-) (limited to 'fable-arch.md') diff --git a/fable-arch.md b/fable-arch.md index 338f8f4..2f29edf 100644 --- a/fable-arch.md +++ b/fable-arch.md @@ -438,13 +438,13 @@ when I run ftt-codegen --run simple.md then log file says scenario "Simple" was run and log file says step "given precondition foo" was run and log file says step "when I do bar" was run -and log file says step "then bar was don" was run +and log file says step "then bar was done" was run and program finished successfully ``` ### simple.md—markdown file -~~~~{#simple.md} +~~~~{#simple.md .markdown} # Simple This is the simplest possible test scenario @@ -457,7 +457,7 @@ then bar was done ### simple.yaml—bindings file -```{#simple.yaml} +```{#simple.yaml .yaml} - given: precondition foo function: precond - when: I do bar @@ -468,19 +468,123 @@ then bar was done ### simple.py—Python file with functions -```{#simple.py} +```{#simple.py .python} +state = {'done': False} def precond(ctx): pass def do(ctx): - pass + state['done'] = True def was_done(ctx): - pass + assert state['done'] ``` ## Two scenarios in the same markdown file -FIXME. +This tests that Fable can run two successful scenarios in the same +Markdown file successfully. + +```fable +given files two.md, two.yaml, and two.py +when I run ftt-codegen --run two.md +then log file says scenario "First" was run +and log file says step "given precondition foo" was run +and log file says step "when I do bar" was run +and log file says step "then bar was done" was run +then log file says scenario "Second" was run +and log file says step "given precondition foo" was run +and log file says step "when I do bar" was run +and log file says step "then bar was done" was run +and program finished successfully +``` + +### two.md—markdown file + +~~~~{#two.md .markdown} +# First +This is the simplest possible test scenario + +```fable +given precondition foo +when I do bar +then bar was done +``` + +# Second +This is another scenario. + +```fable +given precondition foo +when I do bar +then bar was done +``` +~~~~ + +### two.yaml—bindings file + +```{#two.yaml .yaml} +- given: precondition foo + function: precond +- when: I do bar + function: do +- then: bar was done + function: was_done +``` + +### two.md—Python file with functions + +```{#two.py .python} +state = {'done': False} +def precond(ctx): + pass +def do(ctx): + state['done'] = True +def was_done(ctx): + assert state['done'] +``` ## A scenario step fails -FIXME. +This tests that Fable can run handle a scenario step failing. + +```fable +given files fail.md, fail.yaml, and fail.py +when I run ftt-codegen --run fail.md +then log file says scenario "Fail" was run +and log file says step "given precondition foo" was run +and log file says step "then bar was done" failed +and program finished with an error +``` + +### fail.md—markdown file + +~~~~{#fail.md .markdown} +# Fail +This is a scenario that fails. + +```fable +given precondition foo +then bar was done +``` +~~~~ + +### fail.md—bindings file + +```{#fail.yaml .yaml} +- given: precondition foo + function: precond +- then: bar was done + function: was_done +``` + +### fail.md—Python file with functions + +```{#fail.py .python} +state = {'done': False} +def precond(ctx): + pass +def do(ctx): + state['done'] = True +def was_done(ctx): + assert state['done'] +``` + -- cgit v1.2.1