undefined outline scenario test with examples
Этот коммит содержится в:
родитель
f1d2951c54
коммит
51d481d1c7
5 изменённых файлов: 88 добавлений и 24 удалений
8
fmt.go
8
fmt.go
|
@ -311,11 +311,9 @@ func (f *basefmt) Summary() {
|
|||
}
|
||||
case *gherkin.ScenarioOutline:
|
||||
for _, ex := range t.Examples {
|
||||
if examples, hasExamples := examples(ex); hasExamples {
|
||||
total += len(examples.TableBody)
|
||||
if len(t.Steps) == 0 {
|
||||
undefined += len(examples.TableBody)
|
||||
}
|
||||
total += len(ex.TableBody)
|
||||
if len(t.Steps) == 0 {
|
||||
undefined += len(ex.TableBody)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,13 +97,16 @@ func (f *pretty) Node(node interface{}) {
|
|||
f.scenario = nil
|
||||
f.outlineNumExample = -1
|
||||
f.scenarioKeyword = false
|
||||
if isEmptyScenario(t) {
|
||||
f.printUndefinedScenario(t)
|
||||
}
|
||||
case *gherkin.TableRow:
|
||||
f.steps = len(f.outline.Steps) + f.totalBgSteps
|
||||
f.outlineSteps = []*stepResult{}
|
||||
}
|
||||
}
|
||||
|
||||
func (f *pretty) printUndefinedScenario(sc *gherkin.Scenario) {
|
||||
func (f *pretty) printUndefinedScenario(sc interface{}) {
|
||||
if f.bgSteps > 0 {
|
||||
f.commentPos = f.longestStep(f.feature.Background.Steps, f.length(f.feature.Background))
|
||||
fmt.Fprintln(f.out, "\n"+s(f.indent)+whiteb(f.feature.Background.Keyword+": "+f.feature.Background.Name))
|
||||
|
@ -114,10 +117,26 @@ func (f *pretty) printUndefinedScenario(sc *gherkin.Scenario) {
|
|||
}
|
||||
}
|
||||
|
||||
f.commentPos = f.longestStep(sc.Steps, f.length(sc))
|
||||
text := s(f.indent) + whiteb(f.scenario.Keyword+":") + " " + sc.Name
|
||||
text += s(f.commentPos-f.length(f.scenario)+1) + f.line(sc.Location)
|
||||
fmt.Fprintln(f.out, "\n"+text)
|
||||
switch t := sc.(type) {
|
||||
case *gherkin.Scenario:
|
||||
f.commentPos = f.longestStep(t.Steps, f.length(sc))
|
||||
text := s(f.indent) + whiteb(t.Keyword+":") + " " + t.Name
|
||||
text += s(f.commentPos-f.length(t)+1) + f.line(t.Location)
|
||||
fmt.Fprintln(f.out, "\n"+text)
|
||||
case *gherkin.ScenarioOutline:
|
||||
f.commentPos = f.longestStep(t.Steps, f.length(sc))
|
||||
text := s(f.indent) + whiteb(t.Keyword+":") + " " + t.Name
|
||||
text += s(f.commentPos-f.length(t)+1) + f.line(t.Location)
|
||||
fmt.Fprintln(f.out, "\n"+text)
|
||||
|
||||
for _, example := range t.Examples {
|
||||
max := longest(example, cyan)
|
||||
f.printExampleHeader(example, max)
|
||||
for _, row := range example.TableBody {
|
||||
f.printExampleRow(row, max, cyan)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Summary sumarize the feature formatter output
|
||||
|
@ -204,34 +223,45 @@ func (f *pretty) printOutlineExample(outline *gherkin.ScenarioOutline) {
|
|||
if clr == nil {
|
||||
clr = green
|
||||
}
|
||||
cells := make([]string, len(example.TableHeader.Cells))
|
||||
|
||||
max := longest(example, clr, cyan)
|
||||
// an example table header
|
||||
if firstExample {
|
||||
fmt.Fprintln(f.out, "")
|
||||
fmt.Fprintln(f.out, s(f.indent*2)+whiteb(example.Keyword+":")+" "+example.Name)
|
||||
|
||||
for i, cell := range example.TableHeader.Cells {
|
||||
val := cyan(cell.Value)
|
||||
ln := utf8.RuneCountInString(val)
|
||||
cells[i] = val + s(max[i]-ln)
|
||||
}
|
||||
fmt.Fprintln(f.out, s(f.indent*3)+"| "+strings.Join(cells, " | ")+" |")
|
||||
f.printExampleHeader(example, max)
|
||||
}
|
||||
|
||||
// an example table row
|
||||
row := example.TableBody[len(example.TableBody)-f.outlineNumExamples]
|
||||
f.printExampleRow(row, max, clr)
|
||||
|
||||
// if there is an error
|
||||
if msg != "" {
|
||||
fmt.Fprintln(f.out, s(f.indent*4)+redb(msg))
|
||||
}
|
||||
}
|
||||
|
||||
func (f *pretty) printExampleRow(row *gherkin.TableRow, max []int, clr colors.ColorFunc) {
|
||||
cells := make([]string, len(row.Cells))
|
||||
for i, cell := range row.Cells {
|
||||
val := clr(cell.Value)
|
||||
ln := utf8.RuneCountInString(val)
|
||||
cells[i] = val + s(max[i]-ln)
|
||||
}
|
||||
fmt.Fprintln(f.out, s(f.indent*3)+"| "+strings.Join(cells, " | ")+" |")
|
||||
}
|
||||
|
||||
// if there is an error
|
||||
if msg != "" {
|
||||
fmt.Fprintln(f.out, s(f.indent*4)+redb(msg))
|
||||
func (f *pretty) printExampleHeader(example *gherkin.Examples, max []int) {
|
||||
cells := make([]string, len(example.TableHeader.Cells))
|
||||
// an example table header
|
||||
fmt.Fprintln(f.out, "")
|
||||
fmt.Fprintln(f.out, s(f.indent*2)+whiteb(example.Keyword+":")+" "+example.Name)
|
||||
|
||||
for i, cell := range example.TableHeader.Cells {
|
||||
val := cyan(cell.Value)
|
||||
ln := utf8.RuneCountInString(val)
|
||||
cells[i] = val + s(max[i]-ln)
|
||||
}
|
||||
fmt.Fprintln(f.out, s(f.indent*3)+"| "+strings.Join(cells, " | ")+" |")
|
||||
}
|
||||
|
||||
func (f *pretty) printStep(step *gherkin.Step, def *StepDef, c colors.ColorFunc) {
|
||||
|
|
16
formatter-tests/features/with_few_empty_scenarios.feature
Обычный файл
16
formatter-tests/features/with_few_empty_scenarios.feature
Обычный файл
|
@ -0,0 +1,16 @@
|
|||
Feature: few empty scenarios
|
||||
|
||||
Scenario: one
|
||||
|
||||
Scenario Outline: two
|
||||
|
||||
Examples: first group
|
||||
| one | two |
|
||||
| 1 | 2 |
|
||||
| 4 | 7 |
|
||||
|
||||
Examples: second group
|
||||
| one | two |
|
||||
| 5 | 9 |
|
||||
|
||||
Scenario: three
|
|
@ -4,7 +4,7 @@
|
|||
feature
|
||||
|
||||
<bold-white>Scenario:</bold-white> one step passing <black># formatter-tests/features/single_scenario_with_passing_step.feature:6</black>
|
||||
<green>Given</green> <green>a passing step</green> <black># formatters_print_test.go:34 -> github.com/DATA-DOG/godog.TestPrintingFormatters.func4</black>
|
||||
<green>Given</green> <green>a passing step</green> <black># formatters_print_test.go:35 -> github.com/DATA-DOG/godog.TestPrintingFormatters.func4</black>
|
||||
|
||||
1 scenarios (<green>1 passed</green>)
|
||||
1 steps (<green>1 passed</green>)
|
||||
|
|
20
formatter-tests/pretty/with_few_empty_scenarios
Обычный файл
20
formatter-tests/pretty/with_few_empty_scenarios
Обычный файл
|
@ -0,0 +1,20 @@
|
|||
<bold-white>Feature:</bold-white> few empty scenarios
|
||||
|
||||
<bold-white>Scenario:</bold-white> one <black># formatter-tests/features/with_few_empty_scenarios.feature:3</black>
|
||||
|
||||
<bold-white>Scenario Outline:</bold-white> two <black># formatter-tests/features/with_few_empty_scenarios.feature:5</black>
|
||||
|
||||
<bold-white>Examples:</bold-white> first group
|
||||
| <cyan>one</cyan> | <cyan>two</cyan> |
|
||||
| <cyan>1</cyan> | <cyan>2</cyan> |
|
||||
| <cyan>4</cyan> | <cyan>7</cyan> |
|
||||
|
||||
<bold-white>Examples:</bold-white> second group
|
||||
| <cyan>one</cyan> | <cyan>two</cyan> |
|
||||
| <cyan>5</cyan> | <cyan>9</cyan> |
|
||||
|
||||
<bold-white>Scenario:</bold-white> three <black># formatter-tests/features/with_few_empty_scenarios.feature:16</black>
|
||||
|
||||
5 scenarios (<yellow>5 undefined</yellow>)
|
||||
No steps
|
||||
0s
|
Загрузка…
Создание таблицы
Сослаться в новой задаче