Skip to content

Commit

Permalink
added tests for "progress formatter"
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnlon committed Oct 15, 2024
1 parent 184b68b commit 6211b3f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/formatters/fmt_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions internal/formatters/fmt_progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<green>.</green><red>F</red><cyan>-</cyan><yellow>P</yellow><cyan>-</cyan><yellow>U</yellow><cyan>-</cyan> 7
<green>.</green><red>F</red><cyan>-</cyan><yellow>P</yellow><cyan>-</cyan><yellow>U</yellow><cyan>-</cyan><yellow>A</yellow><cyan>-</cyan> 9


--- <red>Failed steps:</red>
Expand All @@ -8,8 +8,8 @@
<red>Error: </red><bold-red>step failed</bold-red>


3 scenarios (<red>1 failed</red>, <yellow>1 pending</yellow>, <yellow>1 undefined</yellow>)
7 steps (<green>1 passed</green>, <red>1 failed</red>, <yellow>1 pending</yellow>, <yellow>1 undefined</yellow>, <cyan>3 skipped</cyan>)
4 scenarios (<red>1 failed</red>, <yellow>1 pending</yellow>, <yellow>1 ambiguous</yellow>, <yellow>1 undefined</yellow>)
9 steps (<green>1 passed</green>, <red>1 failed</red>, <yellow>1 pending</yellow>, <yellow>1 ambiguous</yellow>, <yellow>1 undefined</yellow>, <cyan>4 skipped</cyan>)
0s

<yellow>You can implement step definitions for undefined steps with these snippets:</yellow>
Expand Down

0 comments on commit 6211b3f

Please sign in to comment.