From 47145eb15a4e48e2551fb1c4608540d252aa2754 Mon Sep 17 00:00:00 2001 From: Glib Briia Date: Fri, 26 Jan 2024 15:00:56 +0000 Subject: [PATCH] Use actual line of the step in cucumber formatter --- CHANGELOG.md | 4 ++- features/formatter/cucumber.feature | 4 +-- internal/formatters/fmt_cucumber.go | 4 --- .../formatter-tests/cucumber/scenario_outline | 30 +++++++++---------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0718848..a08a0da7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org). This document is formatted according to the principles of [Keep A CHANGELOG](http://keepachangelog.com). ## Unreleased - +### Fixed +- Remove line overwriting for scenario outlines in cucumber formatter ([605](https://github.com/cucumber/godog/pull/605) - [glibas](https://github.com/glibas)) + ## [v0.13.0] ### Added - Support for reading feature files from an `fs.FS` ([550](https://github.com/cucumber/godog/pull/550) - [tigh-latte](https://github.com/tigh-latte)) diff --git a/features/formatter/cucumber.feature b/features/formatter/cucumber.feature index e4b2cc49..a44380ea 100644 --- a/features/formatter/cucumber.feature +++ b/features/formatter/cucumber.feature @@ -323,7 +323,7 @@ Feature: cucumber json formatter { "keyword": "Given ", "name": "passing step", - "line": 11, + "line": 7, "match": { "location": "suite_context.go:64" }, @@ -345,7 +345,7 @@ Feature: cucumber json formatter { "keyword": "Given ", "name": "failing step", - "line": 12, + "line": 7, "match": { "location": "suite_context.go:47" }, diff --git a/internal/formatters/fmt_cucumber.go b/internal/formatters/fmt_cucumber.go index 8adbfcba..545e3fa0 100644 --- a/internal/formatters/fmt_cucumber.go +++ b/internal/formatters/fmt_cucumber.go @@ -252,10 +252,6 @@ func (f *Cuke) buildCukeStep(pickle *messages.Pickle, stepResult models.PickleSt step := feature.FindStep(pickleStep.AstNodeIds[0]) line := step.Location.Line - if len(pickle.AstNodeIds) == 2 { - _, row := feature.FindExample(pickle.AstNodeIds[1]) - line = row.Location.Line - } cukeStep.Name = pickleStep.Text cukeStep.Line = int(line) diff --git a/internal/formatters/formatter-tests/cucumber/scenario_outline b/internal/formatters/formatter-tests/cucumber/scenario_outline index 5b442522..27b3dc9e 100644 --- a/internal/formatters/formatter-tests/cucumber/scenario_outline +++ b/internal/formatters/formatter-tests/cucumber/scenario_outline @@ -46,7 +46,7 @@ { "keyword": "Given ", "name": "passing step", - "line": 13, + "line": 6, "match": { "location": "fmt_output_test.go:101" }, @@ -58,7 +58,7 @@ { "keyword": "When ", "name": "passing step", - "line": 13, + "line": 7, "match": { "location": "fmt_output_test.go:101" }, @@ -70,7 +70,7 @@ { "keyword": "Then ", "name": "odd 1 and even 2 number", - "line": 13, + "line": 8, "match": { "location": "fmt_output_test.go:103" }, @@ -110,7 +110,7 @@ { "keyword": "Given ", "name": "passing step", - "line": 14, + "line": 6, "match": { "location": "fmt_output_test.go:101" }, @@ -122,7 +122,7 @@ { "keyword": "When ", "name": "passing step", - "line": 14, + "line": 7, "match": { "location": "fmt_output_test.go:101" }, @@ -134,7 +134,7 @@ { "keyword": "Then ", "name": "odd 2 and even 0 number", - "line": 14, + "line": 8, "match": { "location": "fmt_output_test.go:103" }, @@ -175,7 +175,7 @@ { "keyword": "Given ", "name": "passing step", - "line": 15, + "line": 6, "match": { "location": "fmt_output_test.go:101" }, @@ -187,7 +187,7 @@ { "keyword": "When ", "name": "passing step", - "line": 15, + "line": 7, "match": { "location": "fmt_output_test.go:101" }, @@ -199,7 +199,7 @@ { "keyword": "Then ", "name": "odd 3 and even 11 number", - "line": 15, + "line": 8, "match": { "location": "fmt_output_test.go:103" }, @@ -240,7 +240,7 @@ { "keyword": "Given ", "name": "passing step", - "line": 20, + "line": 6, "match": { "location": "fmt_output_test.go:101" }, @@ -252,7 +252,7 @@ { "keyword": "When ", "name": "passing step", - "line": 20, + "line": 7, "match": { "location": "fmt_output_test.go:101" }, @@ -264,7 +264,7 @@ { "keyword": "Then ", "name": "odd 1 and even 14 number", - "line": 20, + "line": 8, "match": { "location": "fmt_output_test.go:103" }, @@ -304,7 +304,7 @@ { "keyword": "Given ", "name": "passing step", - "line": 21, + "line": 6, "match": { "location": "fmt_output_test.go:101" }, @@ -316,7 +316,7 @@ { "keyword": "When ", "name": "passing step", - "line": 21, + "line": 7, "match": { "location": "fmt_output_test.go:101" }, @@ -328,7 +328,7 @@ { "keyword": "Then ", "name": "odd 3 and even 9 number", - "line": 21, + "line": 8, "match": { "location": "fmt_output_test.go:103" },