godog/internal/models/results_test.go
John Lonergan bcf6bce793
ambiguous step def detection akin to cucumber jvm (#636)
* added basic detection for ambiguous steps, but causes an error and not yet recorded in the reports as 'Ambiguous', and no test cases figured out yet

* added initial support for detection of ambiguous steps - further work take a look at how cuke jvm report ambiguous steps and sets the step status to 'ambiguous' rather than my current solution which just blows the test up as a regular step error

* added suite_context_test and also introduced missing 'ambiguous' status to make cucumber jvm'

* update CHANGELOG for ambiguous step defs

* missed file from commit

* added internal/formatters/fmt_multi_test.go

* add tests for other peoples code

* added "ambigous" to the help text

* tests

* added some more tests for attachments

* Update internal/flags/flags.go

Co-authored-by: Viacheslav Poturaev <nanopeni@gmail.com>

---------

Co-authored-by: Viacheslav Poturaev <nanopeni@gmail.com>
2024-07-01 10:28:39 +01:00

54 строки
1,6 КиБ
Go

package models_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/cucumber/godog/colors"
"github.com/cucumber/godog/internal/models"
)
type stepResultStatusTestCase struct {
st models.StepResultStatus
str string
clr colors.ColorFunc
}
var stepResultStatusTestCases = []stepResultStatusTestCase{
{st: models.Passed, str: "passed", clr: colors.Green},
{st: models.Failed, str: "failed", clr: colors.Red},
{st: models.Skipped, str: "skipped", clr: colors.Cyan},
{st: models.Undefined, str: "undefined", clr: colors.Yellow},
{st: models.Pending, str: "pending", clr: colors.Yellow},
{st: models.Ambiguous, str: "ambiguous", clr: colors.Yellow},
{st: -1, str: "unknown", clr: colors.Yellow},
}
func Test_StepResultStatus(t *testing.T) {
for _, tc := range stepResultStatusTestCases {
t.Run(tc.str, func(t *testing.T) {
assert.Equal(t, tc.str, tc.st.String())
assert.Equal(t, tc.clr(tc.str), tc.st.Color()(tc.str))
})
}
}
func Test_NewStepResuklt(t *testing.T) {
status := models.StepResultStatus(123)
pickleID := "pickleId"
pickleStepID := "pickleStepID"
match := &models.StepDefinition{}
attachments := make([]models.PickleAttachment, 0)
err := fmt.Errorf("intentional")
results := models.NewStepResult(status, pickleID, pickleStepID, match, attachments, err)
assert.Equal(t, status, results.Status)
assert.Equal(t, pickleID, results.PickleID)
assert.Equal(t, pickleStepID, results.PickleStepID)
assert.Equal(t, match, results.Def)
assert.Equal(t, attachments, results.Attachments)
assert.Equal(t, err, results.Err)
}