From 7a1b9ad5a910967a41d2032d7a08048b506662f9 Mon Sep 17 00:00:00 2001 From: Kumar Harsh Date: Wed, 29 May 2019 17:12:49 +0530 Subject: [PATCH] fix(output): use bold-black for muted texts Closes #121 --- fmt_pretty.go | 10 ++++----- fmt_progress.go | 4 ++-- .../empty_with_single_scenario_without_steps | 2 +- ...gle_scenario_without_steps_and_description | 2 +- formatter-tests/pretty/scenario_outline | 20 ++++++++--------- .../pretty/scenario_with_background | 10 ++++----- .../scenario_without_steps_with_background | 2 +- .../pretty/single_scenario_with_passing_step | 4 ++-- .../pretty/some_scenarions_including_failing | 22 +++++++++---------- .../pretty/two_scenarios_with_background_fail | 22 +++++++++---------- .../pretty/with_few_empty_scenarios | 6 ++--- suite.go | 2 +- utils.go | 2 +- 13 files changed, 54 insertions(+), 54 deletions(-) diff --git a/fmt_pretty.go b/fmt_pretty.go index 6f1ae67..0ae2446 100644 --- a/fmt_pretty.go +++ b/fmt_pretty.go @@ -153,8 +153,8 @@ func (f *pretty) Summary() { if len(f.failed) > 0 { fmt.Fprintln(f.out, "\n--- "+red("Failed steps:")+"\n") for _, fail := range f.failed { - fmt.Fprintln(f.out, s(2)+red(fail.scenarioDesc())+black(" # "+fail.scenarioLine())) - fmt.Fprintln(f.out, s(4)+red(strings.TrimSpace(fail.step.Keyword)+" "+fail.step.Text)+black(" # "+fail.line())) + fmt.Fprintln(f.out, s(2)+red(fail.scenarioDesc())+blackb(" # "+fail.scenarioLine())) + fmt.Fprintln(f.out, s(4)+red(strings.TrimSpace(fail.step.Keyword)+" "+fail.step.Text)+blackb(" # "+fail.line())) fmt.Fprintln(f.out, s(6)+red("Error: ")+redb(fmt.Sprintf("%+v", fail.err))+"\n") } } @@ -203,7 +203,7 @@ func (f *pretty) printOutlineExample(outline *gherkin.ScenarioOutline) { } else { text = cyan(ostep.Text) } - text += s(f.commentPos-f.length(ostep)+1) + black(fmt.Sprintf("# %s", res.def.definitionID())) + text += s(f.commentPos-f.length(ostep)+1) + blackb(fmt.Sprintf("# %s", res.def.definitionID())) } else { text = cyan(ostep.Text) } @@ -294,7 +294,7 @@ func (f *pretty) printStep(step *gherkin.Step, def *StepDef, c colors.ColorFunc) } else { text += c(step.Text) } - text += s(f.commentPos-f.length(step)+1) + black(fmt.Sprintf("# %s", def.definitionID())) + text += s(f.commentPos-f.length(step)+1) + blackb(fmt.Sprintf("# %s", def.definitionID())) default: text += c(step.Text) } @@ -480,7 +480,7 @@ func (f *pretty) longestStep(steps []*gherkin.Step, base int) int { // a line number representation in feature file func (f *pretty) line(loc *gherkin.Location) string { - return black(fmt.Sprintf("# %s:%d", f.features[len(f.features)-1].Path, loc.Line)) + return blackb(fmt.Sprintf("# %s:%d", f.features[len(f.features)-1].Path, loc.Line)) } func (f *pretty) length(node interface{}) int { diff --git a/fmt_progress.go b/fmt_progress.go index dbbf32c..7003de0 100644 --- a/fmt_progress.go +++ b/fmt_progress.go @@ -58,8 +58,8 @@ func (f *progress) Summary() { if len(f.failed) > 0 { fmt.Fprintln(f.out, "\n--- "+red("Failed steps:")+"\n") for _, fail := range f.failed { - fmt.Fprintln(f.out, s(2)+red(fail.scenarioDesc())+black(" # "+fail.scenarioLine())) - fmt.Fprintln(f.out, s(4)+red(strings.TrimSpace(fail.step.Keyword)+" "+fail.step.Text)+black(" # "+fail.line())) + fmt.Fprintln(f.out, s(2)+red(fail.scenarioDesc())+blackb(" # "+fail.scenarioLine())) + fmt.Fprintln(f.out, s(4)+red(strings.TrimSpace(fail.step.Keyword)+" "+fail.step.Text)+blackb(" # "+fail.line())) fmt.Fprintln(f.out, s(6)+red("Error: ")+redb(fmt.Sprintf("%+v", fail.err))+"\n") } } diff --git a/formatter-tests/pretty/empty_with_single_scenario_without_steps b/formatter-tests/pretty/empty_with_single_scenario_without_steps index bcff7b1..68a5fd7 100644 --- a/formatter-tests/pretty/empty_with_single_scenario_without_steps +++ b/formatter-tests/pretty/empty_with_single_scenario_without_steps @@ -1,6 +1,6 @@ Feature: empty feature - Scenario: without steps # formatter-tests/features/empty_with_single_scenario_without_steps.feature:3 + Scenario: without steps # formatter-tests/features/empty_with_single_scenario_without_steps.feature:3 1 scenarios (1 undefined) No steps diff --git a/formatter-tests/pretty/empty_with_single_scenario_without_steps_and_description b/formatter-tests/pretty/empty_with_single_scenario_without_steps_and_description index 9ac0800..d8c4d05 100644 --- a/formatter-tests/pretty/empty_with_single_scenario_without_steps_and_description +++ b/formatter-tests/pretty/empty_with_single_scenario_without_steps_and_description @@ -3,7 +3,7 @@ an empty feature - Scenario: without steps # formatter-tests/features/empty_with_single_scenario_without_steps_and_description.feature:6 + Scenario: without steps # formatter-tests/features/empty_with_single_scenario_without_steps_and_description.feature:6 1 scenarios (1 undefined) No steps diff --git a/formatter-tests/pretty/scenario_outline b/formatter-tests/pretty/scenario_outline index 3857b64..4796372 100644 --- a/formatter-tests/pretty/scenario_outline +++ b/formatter-tests/pretty/scenario_outline @@ -1,9 +1,9 @@ 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 + 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 | @@ -21,16 +21,16 @@ --- 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 + 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 + 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 + 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 diff --git a/formatter-tests/pretty/scenario_with_background b/formatter-tests/pretty/scenario_with_background index 5d54dc8..e0359a0 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:65 -> passingStepDef - And passing step # formatters_print_test.go:65 -> 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:65 -> passingStepDef - Then 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: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/scenario_without_steps_with_background b/formatter-tests/pretty/scenario_without_steps_with_background index 2ab684f..765e83d 100644 --- a/formatter-tests/pretty/scenario_without_steps_with_background +++ b/formatter-tests/pretty/scenario_without_steps_with_background @@ -3,7 +3,7 @@ Background: Given passing step - Scenario: without steps # formatter-tests/features/scenario_without_steps_with_background.feature:6 + Scenario: without steps # formatter-tests/features/scenario_without_steps_with_background.feature:6 1 scenarios (1 undefined) No steps diff --git a/formatter-tests/pretty/single_scenario_with_passing_step b/formatter-tests/pretty/single_scenario_with_passing_step index c68f8b2..3c4407a 100644 --- a/formatter-tests/pretty/single_scenario_with_passing_step +++ b/formatter-tests/pretty/single_scenario_with_passing_step @@ -3,8 +3,8 @@ a single scenario feature - Scenario: one step passing # formatter-tests/features/single_scenario_with_passing_step.feature:6 - Given a passing step # formatters_print_test.go:65 -> passingStepDef + Scenario: one step passing # formatter-tests/features/single_scenario_with_passing_step.feature:6 + 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 899b5df..4ea88ef 100644 --- a/formatter-tests/pretty/some_scenarions_including_failing +++ b/formatter-tests/pretty/some_scenarions_including_failing @@ -1,24 +1,24 @@ Feature: some scenarios - Scenario: failing # formatter-tests/features/some_scenarions_including_failing.feature:3 - Given passing step # formatters_print_test.go:65 -> passingStepDef - When failing step # formatters_print_test.go:81 -> failingStepDef + Scenario: failing # formatter-tests/features/some_scenarions_including_failing.feature:3 + 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:65 -> 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:79 -> pendingStepDef + Scenario: pending # formatter-tests/features/some_scenarions_including_failing.feature:8 + When pending step # formatters_print_test.go:79 -> pendingStepDef TODO: write pending definition - Then passing step # formatters_print_test.go:65 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef - Scenario: undefined # formatter-tests/features/some_scenarions_including_failing.feature:12 + Scenario: undefined # formatter-tests/features/some_scenarions_including_failing.feature:12 When undefined - Then passing step # formatters_print_test.go:65 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef --- Failed steps: - Scenario: failing # formatter-tests/features/some_scenarions_including_failing.feature:3 - When failing step # formatter-tests/features/some_scenarions_including_failing.feature:5 + Scenario: failing # formatter-tests/features/some_scenarions_including_failing.feature:3 + When failing step # formatter-tests/features/some_scenarions_including_failing.feature:5 Error: step failed diff --git a/formatter-tests/pretty/two_scenarios_with_background_fail b/formatter-tests/pretty/two_scenarios_with_background_fail index 72e0dcc..46416d2 100644 --- a/formatter-tests/pretty/two_scenarios_with_background_fail +++ b/formatter-tests/pretty/two_scenarios_with_background_fail @@ -1,26 +1,26 @@ Feature: two scenarios with background fail Background: - Given passing step # formatters_print_test.go:65 -> passingStepDef - And failing step # formatters_print_test.go:81 -> 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:65 -> passingStepDef - Then passing step # formatters_print_test.go:65 -> passingStepDef + Scenario: one # formatter-tests/features/two_scenarios_with_background_fail.feature:7 + 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 + Scenario: two # formatter-tests/features/two_scenarios_with_background_fail.feature:11 step failed - Then passing step # formatters_print_test.go:65 -> passingStepDef + Then passing step # formatters_print_test.go:65 -> passingStepDef --- Failed steps: - Scenario: one # formatter-tests/features/two_scenarios_with_background_fail.feature:7 - And failing step # formatter-tests/features/two_scenarios_with_background_fail.feature:5 + Scenario: one # formatter-tests/features/two_scenarios_with_background_fail.feature:7 + And failing step # formatter-tests/features/two_scenarios_with_background_fail.feature:5 Error: step failed - Scenario: two # formatter-tests/features/two_scenarios_with_background_fail.feature:11 - And failing step # formatter-tests/features/two_scenarios_with_background_fail.feature:5 + Scenario: two # formatter-tests/features/two_scenarios_with_background_fail.feature:11 + And failing step # formatter-tests/features/two_scenarios_with_background_fail.feature:5 Error: step failed diff --git a/formatter-tests/pretty/with_few_empty_scenarios b/formatter-tests/pretty/with_few_empty_scenarios index 0d36897..2c9a60c 100644 --- a/formatter-tests/pretty/with_few_empty_scenarios +++ b/formatter-tests/pretty/with_few_empty_scenarios @@ -1,8 +1,8 @@ Feature: few empty scenarios - Scenario: one # formatter-tests/features/with_few_empty_scenarios.feature:3 + Scenario: one # formatter-tests/features/with_few_empty_scenarios.feature:3 - Scenario Outline: two # formatter-tests/features/with_few_empty_scenarios.feature:5 + Scenario Outline: two # formatter-tests/features/with_few_empty_scenarios.feature:5 Examples: first group | one | two | @@ -13,7 +13,7 @@ | one | two | | 5 | 9 | - Scenario: three # formatter-tests/features/with_few_empty_scenarios.feature:16 + Scenario: three # formatter-tests/features/with_few_empty_scenarios.feature:16 5 scenarios (5 undefined) No steps diff --git a/suite.go b/suite.go index 54cbe0c..75679eb 100644 --- a/suite.go +++ b/suite.go @@ -609,7 +609,7 @@ func (s *Suite) printStepDefinitions(w io.Writer) { n := utf8.RuneCountInString(def.Expr.String()) location := def.definitionID() spaces := strings.Repeat(" ", longest-n) - fmt.Fprintln(w, yellow(def.Expr.String())+spaces, black("# "+location)) + fmt.Fprintln(w, yellow(def.Expr.String())+spaces, blackb("# "+location)) } if len(s.steps) == 0 { fmt.Fprintln(w, "there were no contexts registered, could not find any step definition..") diff --git a/utils.go b/utils.go index fe824a9..1b5b3a5 100644 --- a/utils.go +++ b/utils.go @@ -11,7 +11,7 @@ var ( red = colors.Red redb = colors.Bold(colors.Red) green = colors.Green - black = colors.Black + blackb = colors.Bold(colors.Black) yellow = colors.Yellow cyan = colors.Cyan cyanb = colors.Bold(colors.Cyan)