Skip to content

Calculated step duration is wrong #615

@iaroslav-ciupin

Description

@iaroslav-ciupin

👓 What did you see?

Produced following report.json

[
    {
        "uri": "test/test.feature",
        "id": "test",
        "keyword": "Feature",
        "name": "Test",
        "description": "",
        "line": 1,
        "elements": [
            {
                "id": "test;test",
                "keyword": "Scenario",
                "name": "Test",
                "description": "",
                "line": 2,
                "type": "scenario",
                "steps": [
                    {
                        "keyword": "When ",
                        "name": "test",
                        "line": 3,
                        "match": {
                            "location": "api_test.go:95"
                        },
                        "result": {
                            "status": "passed",
                            "duration": 27750
                        }
                    },
                    {
                        "keyword": "Then ",
                        "name": "test2",
                        "line": 4,
                        "match": {
                            "location": "api_test.go:98"
                        },
                        "result": {
                            "status": "passed",
                            "duration": 1000527500
                        }
                    }
                ]
            }
        ]
    }
]

✅ What did you expect to see?

1st step should have duration of 1 second.
2nd step should have duration of 2 seconds.

📦 Which tool/library version are you using?

github.com/cucumber/godog v0.14.0

🔬 How could we reproduce it?

Feature file:

Feature: Test
  Scenario: Test
    When test
    Then test2

Go test file:

func Test_WrongDuration(t *testing.T) {
	tSuite := godog.TestSuite{
		ScenarioInitializer: func(ctx *godog.ScenarioContext) {
			ctx.Step("^test$", func() {
				time.Sleep(time.Second)
			})
			ctx.Step("^test2$", func() {
				time.Sleep(2 * time.Second)
			})
		},
		Options: &godog.Options{
			Format:   "cucumber",
			Paths:    []string{"test"},
			TestingT: t,
		},
	}

	code := tSuite.Run()
	if code != 0 {
		t.Fatalf("status returned %d, failed to run feature tests", code)
	}
}

📚 Any additional context?

Also not clear if duration should be rendered in nanoseconds or milliseconds. When I generate HTML report using https://github.com/myie/cucumber-html-reporter as Readme suggests, I get wrong values in HTML, because cucumber-html-reporter assumes duration is in milliseconds. Who is wrong here? is there a well-documented standard for Cucumber json format?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions