Skip to content

Commit

Permalink
switched from tabs to spaces in the ambiguous steps error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnlon committed Oct 15, 2024
1 parent 15d279a commit b21eaa2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
12 changes: 6 additions & 6 deletions internal/formatters/fmt_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,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{"junit,pretty"}
formatters := []string{"cucumber", "events", "junit", "pretty", "progress", "junit,pretty"}
for _, fmtName := range formatters {
for _, featureFile := range featureFiles {
testName := fmt.Sprintf("%s/%s", fmtName, featureFile)
Expand Down Expand Up @@ -86,7 +85,7 @@ func fmtOutputTest(fmtName, testName, featureFilePath string) func(*testing.T) {
att := godog.Attachments(ctx)
attCount := len(att)
if attCount != 4 {
assert.FailNow(tT, "Unexpected attachements: "+sc.Name, "expected 4, found %d", attCount)
assert.FailNow(tT, "Unexpected attachments: "+sc.Name, "expected 4, found %d", attCount)
}
ctx = godog.Attach(ctx,
godog.Attachment{Body: []byte("AfterScenarioAttachment"), FileName: "After Scenario Attachment 2", MediaType: "text/plain"},
Expand Down Expand Up @@ -283,8 +282,8 @@ func compareLists(expected, actual string) {
}

colWid := 60
fmtTitle := fmt.Sprintf("%%4s: %%-%ds | %%-%ds\n", colWid, colWid)
fmtData := fmt.Sprintf("%%4d: %%-%ds | %%-%ds %%s\n", colWid, colWid)
fmtTitle := fmt.Sprintf("%%4s: %%-%ds | %%-%ds\n", colWid+2, colWid+2)
fmtData := fmt.Sprintf("%%4d: %%-%ds | %%-%ds %%s\n", colWid+2, colWid+2)

fmt.Printf(fmtTitle, "#", "expected", "actual")

Expand Down Expand Up @@ -338,8 +337,9 @@ func compareLists(expected, actual string) {
status = "different"
}

delim := "¬"
// Print the wrapped lines with fixed-width column
fmt.Printf(fmtData, i+1, line1, line2, status)
fmt.Printf(fmtData, i+1, delim+line1+delim, delim+line2+delim, status)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
},
"result": {
"status": "ambiguous",
"error_message": "ambiguous step definition, step text: ambiguous step\n\tmatches:\n\t\t^ambiguous step.*$\n\t\t^ambiguous step$"
"error_message": "ambiguous step definition, step text: ambiguous step\n matches:\n ^ambiguous step.*$\n ^ambiguous step$"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{"event":"TestCaseFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:12","timestamp":-6795364578871,"status":"undefined"}
{"event":"TestCaseStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:16","timestamp":-6795364578871}
{"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:17","timestamp":-6795364578871}
{"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:17","timestamp":-6795364578871,"status":"ambiguous","summary":"ambiguous step definition, step text: ambiguous step\n\tmatches:\n\t\t^ambiguous step.*$\n\t\t^ambiguous step$"}
{"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:17","timestamp":-6795364578871,"status":"ambiguous","summary":"ambiguous step definition, step text: ambiguous step\n matches:\n ^ambiguous step.*$\n ^ambiguous step$"}
{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:18","definition_id":"fmt_output_test.go:101 -\u003e github.com/cucumber/godog/internal/formatters_test.passingStepDef","arguments":[]}
{"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:18","timestamp":-6795364578871}
{"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:18","timestamp":-6795364578871,"status":"skipped"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@
<bold-white>Scenario:</bold-white> undefined <bold-black># formatter-tests/features/some_scenarions_including_failing.feature:12</bold-black>
<yellow>When</yellow> <yellow>undefined</yellow>
<cyan>Then</cyan> <cyan>passing step</cyan> <bold-black># fmt_output_test.go:101 -> github.com/cucumber/godog/internal/formatters_test.passingStepDef</bold-black>

<bold-white>Scenario:</bold-white> ambiguous <bold-black># formatter-tests/features/some_scenarions_including_failing.feature:16</bold-black>
<yellow>When</yellow> <yellow>ambiguous step</yellow>
<bold-red>ambiguous step definition, step text: ambiguous step
matches:
^ambiguous step.*$
^ambiguous step$</bold-red>
<cyan>Then</cyan> <cyan>passing step</cyan> <bold-black># fmt_output_test.go:101 -> github.com/cucumber/godog/internal/formatters_test.passingStepDef</bold-black>
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="junit,pretty" tests="3" skipped="0" failures="1" errors="2" time="0">
<testsuite name="some scenarios" tests="3" skipped="0" failures="1" errors="2" time="0">
<testsuites name="junit,pretty" tests="4" skipped="0" failures="1" errors="2" time="0">
<testsuite name="some scenarios" tests="4" skipped="0" failures="1" errors="2" time="0">
<testcase name="failing" status="failed" time="0">
<failure message="Step failing step: step failed"></failure>
<error message="Step passing step" type="skipped"></error>
Expand All @@ -29,6 +37,10 @@
<error message="Step undefined" type="undefined"></error>
<error message="Step passing step" type="skipped"></error>
</testcase>
<testcase name="ambiguous" status="ambiguous" time="0">
<error message="Step ambiguous step" type="ambiguous"></error>
<error message="Step passing step" type="skipped"></error>
</testcase>
</testsuite>
</testsuites>
--- <red>Failed steps:</red>
Expand All @@ -38,8 +50,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
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<bold-white>Scenario:</bold-white> ambiguous <bold-black># formatter-tests/features/some_scenarions_including_failing.feature:16</bold-black>
<yellow>When</yellow> <yellow>ambiguous step</yellow>
<bold-red>ambiguous step definition, step text: ambiguous step
matches:
^ambiguous step.*$
^ambiguous step$</bold-red>
matches:
^ambiguous step.*$
^ambiguous step$</bold-red>
<cyan>Then</cyan> <cyan>passing step</cyan> <bold-black># fmt_output_test.go:XXX -> github.com/cucumber/godog/internal/formatters_test.passingStepDef</bold-black>

--- <red>Failed steps:</red>
Expand Down
5 changes: 2 additions & 3 deletions suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,8 @@ func (s *suite) matchStepTextAndType(text string, stepType messages.PickleStepTy

if s.strict {
if len(matchingExpressions) > 1 {
fmt.Printf("IS STRICT=%v\n", len(matchingExpressions))
errs := "\n\t\t" + strings.Join(matchingExpressions, "\n\t\t")
return nil, fmt.Errorf("%w, step text: %s\n\tmatches:%s", ErrAmbiguous, text, errs)
errs := "\n " + strings.Join(matchingExpressions, "\n ")
return nil, fmt.Errorf("%w, step text: %s\n matches:%s", ErrAmbiguous, text, errs)
}
}

Expand Down

0 comments on commit b21eaa2

Please sign in to comment.