将信息从一个步骤def类传递到另一个步骤的最佳方法是什么? [英] What is the best way to pass information from one steps def class to another?

查看:82
本文介绍了将信息从一个步骤def类传递到另一个步骤的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着步骤def中的重用量增加,将一个步骤def注入到另一个步骤def会迅速导致依赖膨胀。此外,它彼此非常紧密地耦合了步骤def。

Injecting one Steps def into another can rapidly lead to dependency bloat as the amount of re-use among steps defs grows. Furthermore it couples steps defs very tightly to each-other.

必须有更好的方法。有建议吗?

There must be a better way. Any suggestions?

在步骤之间传递信息是否定义了反模式,无论如何都应避免?

Is passing information between steps defs an anti-pattern that should be avoided anyway?

推荐答案

如果您的问题是有关在不同步骤定义类之间共享状态,则可以使用像Spring这样的依赖注入框架来做到这一点。
这是一个博客,解释了(比我现在更能解释):
http://www.thinkcode.se/blog/2017/06/24/sharing-state-between-steps-in-cucumberjvm-using -spring

If your question is about sharing state between different Step Definition classes, you can do this with Dependency Injection frameworks like Spring. Here's a blog that explains (better than I could paraphrase right here): http://www.thinkcode.se/blog/2017/06/24/sharing-state-between-steps-in-cucumberjvm-using-spring

如果您不想使用Spring,则可以使用其他DI框架。

If you don't want to use Spring, there are other DI frameworks you can use.

这篇关于将信息从一个步骤def类传递到另一个步骤的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆