From 9aea023ff29209a4d2b1c62c3746e445c1179f64 Mon Sep 17 00:00:00 2001 From: 0xste Date: Sat, 18 Nov 2023 00:00:07 +0000 Subject: [PATCH 1/3] feat: outputting literal step text as steps as executed when using verbose go test output --- run_doc.go | 2 +- run_scenario.go | 5 ++++- run_step.go | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/run_doc.go b/run_doc.go index bbcc629..e65999e 100644 --- a/run_doc.go +++ b/run_doc.go @@ -31,7 +31,7 @@ func (r *docRunner) runDoc(t *testing.T) { t.Parallel() } - r.runScenario(t, pickle) + r.runScenario(t, pickle, testing.Verbose()) }) } } diff --git a/run_scenario.go b/run_scenario.go index b07ef41..bb1b78b 100644 --- a/run_scenario.go +++ b/run_scenario.go @@ -10,7 +10,7 @@ import ( "github.com/regen-network/gocuke/internal/tag" ) -func (r *docRunner) runScenario(t *testing.T, pickle *messages.Pickle) { +func (r *docRunner) runScenario(t *testing.T, pickle *messages.Pickle, verbose bool) { t.Helper() tags := tag.NewTagsFromPickleTags(pickle.Tags) @@ -57,6 +57,7 @@ func (r *docRunner) runScenario(t *testing.T, pickle *messages.Pickle) { t: t, pickle: pickle, stepDefs: stepDefs, + verbose: verbose, }).runTestCase() }) } else { @@ -65,6 +66,7 @@ func (r *docRunner) runScenario(t *testing.T, pickle *messages.Pickle) { t: t, pickle: pickle, stepDefs: stepDefs, + verbose: verbose, }).runTestCase() } } @@ -76,6 +78,7 @@ type scenarioRunner struct { pickle *messages.Pickle stepDefs []*stepDef step *messages.PickleStep + verbose bool } func (r *scenarioRunner) runTestCase() { diff --git a/run_step.go b/run_step.go index 93aa45a..365e7ea 100644 --- a/run_step.go +++ b/run_step.go @@ -96,5 +96,9 @@ func (r *scenarioRunner) runStep(step *messages.PickleStep, def *stepDef) { } } + if r.verbose { + r.t.Logf("Step: %s", step.Text) + } + def.theFunc.Call(values) } From f210286b66a46784605971567e481c3c0bc76f6b Mon Sep 17 00:00:00 2001 From: Stefano Date: Tue, 21 Nov 2023 09:55:45 +0000 Subject: [PATCH 2/3] chore: readme updated to include verbose detail --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 94ccc47..316cc8a 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,7 @@ tests. `Runner.ShortTags` method can be used to select a set of tags to * `Before()`, `After()`, `BeforeStep()`, or and `AfterStep()` can be used to register custom hooks. * `Tags` and `ShortTags` can be used with tag expressions as described above. * `NonParallel()` disables parallel tests. +* `--verbose` or `-v` in your go-tests will emit the current test step definition to stdout while your tests are running, this is useful for testing ### Property-based testing using Rapid From 16ddfb72cfafa896a79a91072f37d70c4a6bc4d9 Mon Sep 17 00:00:00 2001 From: Stefano Date: Thu, 23 Nov 2023 21:35:53 +0000 Subject: [PATCH 3/3] chore: update readme Co-authored-by: Aaron Craelius --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 316cc8a..d5d5f13 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ tests. `Runner.ShortTags` method can be used to select a set of tags to * `Before()`, `After()`, `BeforeStep()`, or and `AfterStep()` can be used to register custom hooks. * `Tags` and `ShortTags` can be used with tag expressions as described above. * `NonParallel()` disables parallel tests. -* `--verbose` or `-v` in your go-tests will emit the current test step definition to stdout while your tests are running, this is useful for testing +* `--verbose` or `-v` with `go test` will emit the current test step definition to stdout while your tests are running, this is useful for debugging failing tests. ### Property-based testing using Rapid