Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: outputting literal step text as steps as executed when using verbose go test output #20

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
0xste marked this conversation as resolved.
Show resolved Hide resolved

### Property-based testing using Rapid

Expand Down
2 changes: 1 addition & 1 deletion run_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (r *docRunner) runDoc(t *testing.T) {
t.Parallel()
}

r.runScenario(t, pickle)
r.runScenario(t, pickle, testing.Verbose())
})
}
}
5 changes: 4 additions & 1 deletion run_scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -57,6 +57,7 @@ func (r *docRunner) runScenario(t *testing.T, pickle *messages.Pickle) {
t: t,
pickle: pickle,
stepDefs: stepDefs,
verbose: verbose,
}).runTestCase()
})
} else {
Expand All @@ -65,6 +66,7 @@ func (r *docRunner) runScenario(t *testing.T, pickle *messages.Pickle) {
t: t,
pickle: pickle,
stepDefs: stepDefs,
verbose: verbose,
}).runTestCase()
}
}
Expand All @@ -76,6 +78,7 @@ type scenarioRunner struct {
pickle *messages.Pickle
stepDefs []*stepDef
step *messages.PickleStep
verbose bool
}

func (r *scenarioRunner) runTestCase() {
Expand Down
4 changes: 4 additions & 0 deletions run_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading