【发布时间】:2020-07-11 21:39:03
【问题描述】:
为了符合并发要求,我想知道如何在Godog 中的多个步骤之间传递参数或状态。
func FeatureContext(s *godog.Suite) {
// This step is called in background
s.Step(`^I work with "([^"]*)" entities`, iWorkWithEntities)
// This step should know about the type of entity
s.Step(`^I run the "([^"]*)" mutation with the arguments:$`, iRunTheMutationWithTheArguments)
我想到的唯一想法是内联被调用的函数:
state := make(map[string]string, 0)
s.Step(`^I work with "([^"]*)" entities`, func(entityName string) error {
return iWorkWithEntities(entityName, state)
})
s.Step(`^I run the "([^"]*)" mutation with the arguments:$`, func(mutationName string, args *messages.PickleStepArgument_PickleTable) error {
return iRunTheMutationWithTheArguments(mutationName, args, state)
})
但这感觉有点像解决方法。 Godog 库本身是否有任何功能可以传递这些信息?
【问题讨论】:
标签: go concurrency cucumber gherkin