如何传递变量&黄瓜jvm方案之间的值 [英] How to pass variable & values between cucumber jvm scenarios
本文介绍了如何传递变量&黄瓜jvm方案之间的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个方案A和B。我将'A'方案的字段输出值存储在变量中。现在,我必须在场景 B中使用该变量。我如何在黄瓜Java中将变量及其值从一种情况传递到另一种情况
I have two scenarios A and B. I am storing the value of a field output of 'A' scenario in a variable. Now i have to use that variable in the Scenario 'B'. How can i pass a variable and its value from one scenario to other in Cucumber Java
推荐答案
如果您的步骤定义尚不清楚,这些场景在不同的类中,但是我认为它们是这样,并且场景A中的步骤在B中的步骤之前执行。
It's not entirely clear if your step definitions for these scenarios are in separate classes, but I assume they are and that the step in ScenarioA is executed before the one in B.
public class ScenarioA {
public static String getVariableYouWantToUse() {
return variableYouWantToUse;
}
private static String variableYouWantToUse;
Given("your step that expects one parameter")
public void some_step(String myVariable)
variableYouWantToUse = myVariable;
}
然后在场景B中。
public class ScenarioB {
Given("other step")
public void some_other_step()
ScenarioA.getVariableYouWantToUse();
}
这篇关于如何传递变量&黄瓜jvm方案之间的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文