From 6211b3f11ba3a988f7b95b47516d9ab6f1ce3d0a Mon Sep 17 00:00:00 2001
From: Johnlon <836248+Johnlon@users.noreply.github.com>
Date: Tue, 15 Oct 2024 04:36:11 +0100
Subject: [PATCH] added tests for "progress formatter"
---
internal/formatters/fmt_output_test.go | 2 +-
internal/formatters/fmt_progress.go | 12 ++++++++++++
.../progress/some_scenarions_including_failing | 6 +++---
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/internal/formatters/fmt_output_test.go b/internal/formatters/fmt_output_test.go
index a8c429a3..2d91d7bb 100644
--- a/internal/formatters/fmt_output_test.go
+++ b/internal/formatters/fmt_output_test.go
@@ -29,7 +29,7 @@ func Test_FmtOutput(t *testing.T) {
featureFiles, err := listFmtOutputTestsFeatureFiles()
require.Nil(t, err)
// formatters := []string{"cucumber", "events", "junit", "pretty", "progress", "junit,pretty"}
- formatters := []string{"pretty"} //, "junit", "pretty", "progress", "junit,pretty"}
+ formatters := []string{"junit,pretty"}
for _, fmtName := range formatters {
for _, featureFile := range featureFiles {
testName := fmt.Sprintf("%s/%s", fmtName, featureFile)
diff --git a/internal/formatters/fmt_progress.go b/internal/formatters/fmt_progress.go
index 23086963..9722ef7a 100644
--- a/internal/formatters/fmt_progress.go
+++ b/internal/formatters/fmt_progress.go
@@ -98,6 +98,8 @@ func (f *Progress) step(pickleStepID string) {
fmt.Fprint(f.out, red("F"))
case undefined:
fmt.Fprint(f.out, yellow("U"))
+ case ambiguous:
+ fmt.Fprint(f.out, yellow("A"))
case pending:
fmt.Fprint(f.out, yellow("P"))
}
@@ -149,6 +151,16 @@ func (f *Progress) Failed(pickle *messages.Pickle, step *messages.PickleStep, ma
f.step(step.Id)
}
+// Ambiguous steps.
+func (f *Progress) Ambiguous(pickle *messages.Pickle, step *messages.PickleStep, match *formatters.StepDefinition, err error) {
+ f.Base.Ambiguous(pickle, step, match, err)
+
+ f.Lock.Lock()
+ defer f.Lock.Unlock()
+
+ f.step(step.Id)
+}
+
// Pending captures pending step.
func (f *Progress) Pending(pickle *messages.Pickle, step *messages.PickleStep, match *formatters.StepDefinition) {
f.Base.Pending(pickle, step, match)
diff --git a/internal/formatters/formatter-tests/progress/some_scenarions_including_failing b/internal/formatters/formatter-tests/progress/some_scenarions_including_failing
index 43146dff..73ce80ae 100644
--- a/internal/formatters/formatter-tests/progress/some_scenarions_including_failing
+++ b/internal/formatters/formatter-tests/progress/some_scenarions_including_failing
@@ -1,4 +1,4 @@
-.F-P-U- 7
+.F-P-U-A- 9
--- Failed steps:
@@ -8,8 +8,8 @@
Error: step failed
-3 scenarios (1 failed, 1 pending, 1 undefined)
-7 steps (1 passed, 1 failed, 1 pending, 1 undefined, 3 skipped)
+4 scenarios (1 failed, 1 pending, 1 ambiguous, 1 undefined)
+9 steps (1 passed, 1 failed, 1 pending, 1 ambiguous, 1 undefined, 4 skipped)
0s
You can implement step definitions for undefined steps with these snippets: