Fixed broken tests
Этот коммит содержится в:
родитель
d7e8f831e8
коммит
edafd7752d
7 изменённых файлов: 42 добавлений и 32 удалений
|
@ -135,6 +135,7 @@ func (f *cukefmt) Pickle(pickle *messages.Pickle) {
|
|||
f.curElement.Keyword = scenario.Keyword
|
||||
f.curElement.ID = f.curFeature.ID + ";" + makeID(pickle.Name)
|
||||
f.curElement.Type = "scenario"
|
||||
|
||||
f.curElement.Tags = make([]cukeTag, len(scenario.Tags)+len(f.curFeature.Tags))
|
||||
|
||||
if len(f.curElement.Tags) > 0 {
|
||||
|
@ -148,17 +149,22 @@ func (f *cukefmt) Pickle(pickle *messages.Pickle) {
|
|||
}
|
||||
}
|
||||
|
||||
if len(pickle.AstNodeIds) == 1 {
|
||||
return
|
||||
}
|
||||
|
||||
example, _ := f.findExample(pickle.AstNodeIds[1])
|
||||
// apply example level tags.
|
||||
for _, tag := range example.Tags {
|
||||
tag := cukeTag{Line: int(tag.Location.Line), Name: tag.Name}
|
||||
f.curElement.Tags = append(f.curElement.Tags, tag)
|
||||
}
|
||||
|
||||
examples := scenario.GetExamples()
|
||||
if len(examples) > 0 {
|
||||
rowID := pickle.AstNodeIds[1]
|
||||
|
||||
for _, example := range examples {
|
||||
// apply example level tags.
|
||||
for _, element := range example.Tags {
|
||||
tag := cukeTag{Line: int(element.Location.Line), Name: element.Name}
|
||||
f.curElement.Tags = append(f.curElement.Tags, tag)
|
||||
}
|
||||
|
||||
for idx, row := range example.TableBody {
|
||||
if rowID == row.Id {
|
||||
f.curElement.ID += fmt.Sprintf(";%s;%d", makeID(example.Name), idx+2)
|
||||
|
@ -223,8 +229,14 @@ func (f *cukefmt) Defined(pickle *messages.Pickle, pickleStep *messages.Pickle_P
|
|||
|
||||
step := f.findStep(pickleStep.AstNodeIds[0])
|
||||
|
||||
line := step.Location.Line
|
||||
if len(pickle.AstNodeIds) == 2 {
|
||||
_, row := f.findExample(pickle.AstNodeIds[1])
|
||||
line = row.Location.Line
|
||||
}
|
||||
|
||||
f.curStep.Name = pickleStep.Text
|
||||
f.curStep.Line = int(step.Location.Line)
|
||||
f.curStep.Line = int(line)
|
||||
f.curStep.Keyword = step.Keyword
|
||||
|
||||
arg := pickleStep.Argument
|
||||
|
|
|
@ -56,21 +56,17 @@ func (f *events) event(ev interface{}) {
|
|||
func (f *events) Pickle(pickle *messages.Pickle) {
|
||||
f.basefmt.Pickle(pickle)
|
||||
|
||||
scenario := f.findScenario(pickle.AstNodeIds[0])
|
||||
id := fmt.Sprintf("%s:%d", f.path, scenario.Location.Line)
|
||||
undefined := len(pickle.Steps) == 0
|
||||
|
||||
f.event(&struct {
|
||||
Event string `json:"event"`
|
||||
Location string `json:"location"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}{
|
||||
"TestCaseStarted",
|
||||
id,
|
||||
f.scenarioLocation(pickle.AstNodeIds),
|
||||
timeNowFunc().UnixNano() / nanoSec,
|
||||
})
|
||||
|
||||
if undefined {
|
||||
if len(pickle.Steps) == 0 {
|
||||
// @TODO: is status undefined or passed? when there are no steps
|
||||
// for this scenario
|
||||
f.event(&struct {
|
||||
|
@ -80,7 +76,7 @@ func (f *events) Pickle(pickle *messages.Pickle) {
|
|||
Status string `json:"status"`
|
||||
}{
|
||||
"TestCaseFinished",
|
||||
id,
|
||||
f.scenarioLocation(pickle.AstNodeIds),
|
||||
timeNowFunc().UnixNano() / nanoSec,
|
||||
"undefined",
|
||||
})
|
||||
|
@ -155,11 +151,7 @@ func (f *events) step(res *stepResult) {
|
|||
errMsg,
|
||||
})
|
||||
|
||||
scenario := f.findScenario(res.owner.AstNodeIds[0])
|
||||
line := scenario.Location.Line
|
||||
finished := isLastStep(res.owner, res.step)
|
||||
|
||||
if finished {
|
||||
if isLastStep(res.owner, res.step) {
|
||||
f.event(&struct {
|
||||
Event string `json:"event"`
|
||||
Location string `json:"location"`
|
||||
|
@ -167,7 +159,7 @@ func (f *events) step(res *stepResult) {
|
|||
Status string `json:"status"`
|
||||
}{
|
||||
"TestCaseFinished",
|
||||
fmt.Sprintf("%s:%d", f.path, line),
|
||||
f.scenarioLocation(res.owner.AstNodeIds),
|
||||
timeNowFunc().UnixNano() / nanoSec,
|
||||
f.status.String(),
|
||||
})
|
||||
|
@ -249,3 +241,14 @@ func (f *events) Pending(pickle *messages.Pickle, step *messages.Pickle_PickleSt
|
|||
f.status = pending
|
||||
f.step(f.lastStepResult())
|
||||
}
|
||||
|
||||
func (f *events) scenarioLocation(astNodeIds []string) string {
|
||||
scenario := f.findScenario(astNodeIds[0])
|
||||
line := scenario.Location.Line
|
||||
if len(astNodeIds) == 2 {
|
||||
_, row := f.findExample(astNodeIds[1])
|
||||
line = row.Location.Line
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%d", f.path, line)
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func (f *pretty) Pending(pickle *messages.Pickle, step *messages.Pickle_PickleSt
|
|||
}
|
||||
|
||||
func (f *pretty) printFeature(feature *messages.GherkinDocument_Feature) {
|
||||
if len(f.features) != 0 {
|
||||
if len(f.features) > 1 {
|
||||
fmt.Fprintln(f.out, "") // not a first feature, add a newline
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ func (f *pretty) printUndefinedPickle(pickle *messages.Pickle) {
|
|||
if astBackground != nil {
|
||||
fmt.Fprintln(f.out, "\n"+s(f.indent)+keywordAndName(astBackground.Keyword, astBackground.Name))
|
||||
for _, step := range astBackground.Steps {
|
||||
text := s(f.indent) + cyan(strings.TrimSpace(step.Keyword)) + " " + cyan(step.Text)
|
||||
text := s(f.indent*2) + cyan(strings.TrimSpace(step.Keyword)) + " " + cyan(step.Text)
|
||||
fmt.Fprintln(f.out, text)
|
||||
}
|
||||
}
|
||||
|
@ -161,9 +161,9 @@ func (f *pretty) Summary() {
|
|||
astStep := f.findStep(fail.step.AstNodeIds[0])
|
||||
stepDesc := strings.TrimSpace(astStep.Keyword) + " " + fail.step.Text
|
||||
|
||||
fmt.Fprintln(f.out, s(2)+red(scenarioDesc)+f.line(astScenario.Location))
|
||||
fmt.Fprintln(f.out, s(4)+red(stepDesc)+f.line(astStep.Location))
|
||||
fmt.Fprintln(f.out, s(6)+red("Error: ")+redb(fmt.Sprintf("%+v", fail.err))+"\n")
|
||||
fmt.Fprintln(f.out, s(f.indent)+red(scenarioDesc)+f.line(astScenario.Location))
|
||||
fmt.Fprintln(f.out, s(f.indent*2)+red(stepDesc)+f.line(astStep.Location))
|
||||
fmt.Fprintln(f.out, s(f.indent*3)+red("Error: ")+redb(fmt.Sprintf("%+v", fail.err))+"\n")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ func (f *pretty) printStep(result *stepResult) {
|
|||
f.printScenarioHeader(astScenario, maxLength-scenarioHeaderLength)
|
||||
}
|
||||
|
||||
text := s(f.indent) + result.status.clr()(strings.TrimSpace(astStep.Keyword)) + " " + result.status.clr()(astStep.Text)
|
||||
text := s(f.indent*2) + result.status.clr()(strings.TrimSpace(astStep.Keyword)) + " " + result.status.clr()(astStep.Text)
|
||||
if result.def != nil {
|
||||
text += s(maxLength - stepLength + 1)
|
||||
text += blackb("# " + result.def.definitionID())
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{"event":"TestRunStarted","version":"0.1.0","timestamp":-6795364578871,"suite":"events"}
|
||||
{"event":"TestSource","location":"formatter-tests/features/scenario_outline.feature:2","source":"@outline @tag\nFeature: outline\n\n @scenario\n Scenario Outline: outline\n Given passing step\n When passing step\n Then odd \u003codd\u003e and even \u003ceven\u003e number\n\n @tagged\n Examples: tagged\n | odd | even |\n | 1 | 2 |\n | 2 | 0 |\n | 3 | 11 |\n\n @tag2\n Examples:\n | odd | even |\n | 1 | 14 |\n | 3 | 9 |\n\n"}
|
||||
{"event":"TestSource","location":"formatter-tests/features/scenario_outline.feature:2","source":"@outline @tag\nFeature: outline\n\n @scenario\n Scenario Outline: outline\n Given passing step\n When passing step\n Then odd \u003codd\u003e and even \u003ceven\u003e number\n\n @tagged\n Examples: tagged\n | odd | even |\n | 1 | 2 |\n | 2 | 0 |\n | 3 | 11 |\n\n @tag2\n Examples:\n | odd | even |\n | 1 | 14 |\n | 3 | 9 |\n"}
|
||||
{"event":"TestCaseStarted","location":"formatter-tests/features/scenario_outline.feature:13","timestamp":-6795364578871}
|
||||
{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]}
|
||||
{"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871}
|
||||
|
|
|
@ -19,4 +19,3 @@ Feature: outline
|
|||
| odd | even |
|
||||
| 1 | 14 |
|
||||
| 3 | 9 |
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<cyan>Then</cyan> <cyan>passing step</cyan> <bold-black># formatters_print_test.go:63 -> passingStepDef</bold-black>
|
||||
|
||||
<bold-white>Scenario:</bold-white> two <bold-black># formatter-tests/features/two_scenarios_with_background_fail.feature:11</bold-black>
|
||||
<bold-red>step failed</bold-red>
|
||||
<cyan>Then</cyan> <cyan>passing step</cyan> <bold-black># formatters_print_test.go:63 -> passingStepDef</bold-black>
|
||||
|
||||
--- <red>Failed steps:</red>
|
||||
|
|
|
@ -51,10 +51,7 @@ func TestPrintingFormatters(t *testing.T) {
|
|||
suite.fmt.Summary()
|
||||
|
||||
expected := string(expectedOutput)
|
||||
expected = trimAllLines(expected)
|
||||
|
||||
actual := buf.String()
|
||||
actual = trimAllLines(actual)
|
||||
|
||||
assert.Equalf(t, expected, actual, "path: %s", expectOutputPath)
|
||||
}
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче