Skip to content

Any tool analysis steps running time. #432

Answered by vearutop
nvcnvn asked this question in Q&A
Discussion options

You must be logged in to vote

I think you can try collecting such stats with step/scenario hooks.

suite := godog.TestSuite{}
suite.ScenarioInitializer = func(scenarioContext *godog.ScenarioContext) {
	// Step definitions ....

	type ctxStarted struct{}
	scenarioContext.StepContext().Before(func(ctx context.Context, st *godog.Step) (context.Context, error) {
		started := time.Now()
		return context.WithValue(ctx, ctxStarted{}, started), nil
	})

	scenarioContext.StepContext().After(func(ctx context.Context, st *godog.Step, status godog.StepResultStatus, err error) (context.Context, error) {
		if started, ok := ctx.Value(ctxStarted{}).(time.Time); ok {
			time.Since(started)

			fmt.Println(st.Text, time.Since(started).S…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by nvcnvn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants