From f362a632aa707dce494cb2842a8c36277368c4ec Mon Sep 17 00:00:00 2001 From: gedi Date: Fri, 16 Nov 2018 10:04:48 +0200 Subject: [PATCH] outline scenario with failing steps pretty print test --- .../features/scenario_outline.feature | 22 +++++++++++ formatter-tests/pretty/scenario_outline | 39 +++++++++++++++++++ .../pretty/scenario_with_background | 8 ++-- .../pretty/single_scenario_with_passing_step | 2 +- .../pretty/some_scenarions_including_failing | 12 +++--- .../pretty/two_scenarios_with_background_fail | 10 ++--- formatters_print_test.go | 5 ++- 7 files changed, 80 insertions(+), 18 deletions(-) create mode 100644 formatter-tests/features/scenario_outline.feature create mode 100644 formatter-tests/pretty/scenario_outline diff --git a/formatter-tests/features/scenario_outline.feature b/formatter-tests/features/scenario_outline.feature new file mode 100644 index 0000000..3691ce3 --- /dev/null +++ b/formatter-tests/features/scenario_outline.feature @@ -0,0 +1,22 @@ +@outline @tag +Feature: outline + + @scenario + Scenario Outline: outline + Given passing step + When passing step + Then odd and even number + + @tagged + Examples: tagged + | odd | even | + | 1 | 2 | + | 2 | 0 | + | 3 | 11 | + + @tag2 + Examples: + | odd | even | + | 1 | 14 | + | 3 | 9 | + diff --git a/formatter-tests/pretty/scenario_outline b/formatter-tests/pretty/scenario_outline new file mode 100644 index 0000000..3857b64 --- /dev/null +++ b/formatter-tests/pretty/scenario_outline @@ -0,0 +1,39 @@ +Feature: outline + + Scenario Outline: outline # formatter-tests/features/scenario_outline.feature:5 + Given passing step # formatters_print_test.go:65 -> passingStepDef + When passing step # formatters_print_test.go:65 -> passingStepDef + Then odd and even number # formatters_print_test.go:67 -> oddEvenStepDef + + Examples: tagged + | odd | even | + | 1 | 2 | + | 2 | 0 | + 2 is not odd + | 3 | 11 | + 11 is not even + + Examples: + | odd | even | + | 1 | 14 | + | 3 | 9 | + 9 is not even + +--- Failed steps: + + Scenario Outline: outline # formatter-tests/features/scenario_outline.feature:5 + Then odd 2 and even 0 number # formatter-tests/features/scenario_outline.feature:8 + Error: 2 is not odd + + Scenario Outline: outline # formatter-tests/features/scenario_outline.feature:5 + Then odd 3 and even 11 number # formatter-tests/features/scenario_outline.feature:8 + Error: 11 is not even + + Scenario Outline: outline # formatter-tests/features/scenario_outline.feature:5 + Then odd 3 and even 9 number # formatter-tests/features/scenario_outline.feature:8 + Error: 9 is not even + + +5 scenarios (2 passed, 3 failed) +15 steps (12 passed, 3 failed) +0s diff --git a/formatter-tests/pretty/scenario_with_background b/formatter-tests/pretty/scenario_with_background index d9f05c9..5d54dc8 100644 --- a/formatter-tests/pretty/scenario_with_background +++ b/formatter-tests/pretty/scenario_with_background @@ -1,12 +1,12 @@ Feature: single scenario with background Background: named - Given passing step # formatters_print_test.go:64 -> passingStepDef - And passing step # formatters_print_test.go:64 -> passingStepDef + Given passing step # formatters_print_test.go:65 -> passingStepDef + And passing step # formatters_print_test.go:65 -> passingStepDef Scenario: scenario # formatter-tests/features/scenario_with_background.feature:7 - When passing step # formatters_print_test.go:64 -> passingStepDef - Then passing step # formatters_print_test.go:64 -> passingStepDef + When passing step # formatters_print_test.go:65 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef 1 scenarios (1 passed) 4 steps (4 passed) diff --git a/formatter-tests/pretty/single_scenario_with_passing_step b/formatter-tests/pretty/single_scenario_with_passing_step index 2e06272..c68f8b2 100644 --- a/formatter-tests/pretty/single_scenario_with_passing_step +++ b/formatter-tests/pretty/single_scenario_with_passing_step @@ -4,7 +4,7 @@ feature Scenario: one step passing # formatter-tests/features/single_scenario_with_passing_step.feature:6 - Given a passing step # formatters_print_test.go:64 -> passingStepDef + Given a passing step # formatters_print_test.go:65 -> passingStepDef 1 scenarios (1 passed) 1 steps (1 passed) diff --git a/formatter-tests/pretty/some_scenarions_including_failing b/formatter-tests/pretty/some_scenarions_including_failing index 0a19cb6..899b5df 100644 --- a/formatter-tests/pretty/some_scenarions_including_failing +++ b/formatter-tests/pretty/some_scenarions_including_failing @@ -1,19 +1,19 @@ Feature: some scenarios Scenario: failing # formatter-tests/features/some_scenarions_including_failing.feature:3 - Given passing step # formatters_print_test.go:64 -> passingStepDef - When failing step # formatters_print_test.go:80 -> failingStepDef + Given passing step # formatters_print_test.go:65 -> passingStepDef + When failing step # formatters_print_test.go:81 -> failingStepDef step failed - Then passing step # formatters_print_test.go:64 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef Scenario: pending # formatter-tests/features/some_scenarions_including_failing.feature:8 - When pending step # formatters_print_test.go:78 -> pendingStepDef + When pending step # formatters_print_test.go:79 -> pendingStepDef TODO: write pending definition - Then passing step # formatters_print_test.go:64 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef Scenario: undefined # formatter-tests/features/some_scenarions_including_failing.feature:12 When undefined - Then passing step # formatters_print_test.go:64 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef --- Failed steps: diff --git a/formatter-tests/pretty/two_scenarios_with_background_fail b/formatter-tests/pretty/two_scenarios_with_background_fail index 3a4f89f..72e0dcc 100644 --- a/formatter-tests/pretty/two_scenarios_with_background_fail +++ b/formatter-tests/pretty/two_scenarios_with_background_fail @@ -1,17 +1,17 @@ Feature: two scenarios with background fail Background: - Given passing step # formatters_print_test.go:64 -> passingStepDef - And failing step # formatters_print_test.go:80 -> failingStepDef + Given passing step # formatters_print_test.go:65 -> passingStepDef + And failing step # formatters_print_test.go:81 -> failingStepDef step failed Scenario: one # formatter-tests/features/two_scenarios_with_background_fail.feature:7 - When passing step # formatters_print_test.go:64 -> passingStepDef - Then passing step # formatters_print_test.go:64 -> passingStepDef + When passing step # formatters_print_test.go:65 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef Scenario: two # formatter-tests/features/two_scenarios_with_background_fail.feature:11 step failed - Then passing step # formatters_print_test.go:64 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef --- Failed steps: diff --git a/formatters_print_test.go b/formatters_print_test.go index 4c0b7fa..0f245d3 100644 --- a/formatters_print_test.go +++ b/formatters_print_test.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "path" "strings" "testing" ) @@ -26,14 +27,14 @@ func TestPrintingFormatters(t *testing.T) { suite.Step(`^(?:a )?failing step`, failingStepDef) suite.Step(`^(?:a )?pending step$`, pendingStepDef) suite.Step(`^(?:a )?passing step$`, passingStepDef) - suite.Step(`^is and number$`, oddEvenStepDef) + suite.Step(`^odd (\d+) and even (\d+) number$`, oddEvenStepDef) pkg := os.Getenv("GODOG_TESTED_PACKAGE") os.Setenv("GODOG_TESTED_PACKAGE", "github.com/DATA-DOG/godog") for _, feat := range features { for name := range AvailableFormatters() { expectOutputPath := strings.Replace(feat.Path, "features", name, 1) - expectOutputPath = strings.TrimRight(expectOutputPath, ".feature") + expectOutputPath = strings.TrimSuffix(expectOutputPath, path.Ext(expectOutputPath)) if _, err := os.Stat(expectOutputPath); err != nil { continue }