Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculated step duration is wrong #615

Closed
iaroslav-ciupin opened this issue Apr 3, 2024 · 3 comments
Closed

Calculated step duration is wrong #615

iaroslav-ciupin opened this issue Apr 3, 2024 · 3 comments

Comments

@iaroslav-ciupin
Copy link
Contributor

iaroslav-ciupin commented Apr 3, 2024

👓 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?

@iaroslav-ciupin
Copy link
Contributor Author

@l3pp4rd @lonnblad can somebody of you take a look and confirm if bug is valid? also please note 2nd question about time duration units

@iaroslav-ciupin
Copy link
Contributor Author

#616 opened a PR for 1st part

@iaroslav-ciupin
Copy link
Contributor Author

iaroslav-ciupin commented Apr 9, 2024

Looks like both godog and latest version of cucumber-html-reporter are using nanoseconds and report shows duration as expected. I was initially using cucumber-html-reporter 3.0.4 as was mentioned here, which apparently doesn't expect nanoseconds. Closing issue as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant