cucumber / cucumber/godog

Use "state" pattern in `suite.runSteps`

Open
#446 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.7k
Forks
280
Avg merge
2d 20h
Merged PRs (30d)
2

Description

The [`runStep` function](https://github.com/cucumber/godog/blob/b850b44b48b7cb1ff1668b2c789084251f6fd81a/suite.go#L75) has a bunch of conditional logic in it, which I think could be simplified by the application of the [State](https://sourcemaking.com/design_patterns/state) design pattern.

We use this [in the Ruby version](https://github.com/cucumber/cucumber-ruby-core/blob/main/lib/cucumber/core/test/runner.rb#L96), and pretty much eliminated every `if` statement, meaning a whole class of bugs like https://github.com/cucumber/godog/issues/434 disappeared.

What do folks think? Could we do something like this? Would it be useful?

Contributor guide

Open the contributing guide

Research direction

Start by reading suite.go, especially the runStep function linked in the issue, and compare it with the Ruby runner implementation. Trace the conditional states and review issue #434 for the bug context. Done means agreeing on a useful State-pattern design and implementing it without changing runSteps behavior, with tests covering the affected transitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.