我尝试重复使用现有的Step-def实现中的一些,在@And
/ @Given
@When
标记
但如果我将@Given
置于其上,则会禁用@And
的现有链接
&安培;如果我将@And
放在@Given
@And("^User sends SMS \"([^\"]*)\"$")
@When("^User sends the command \"([^\"]*)\"$")
public void User_sends_the_command(String sUserCommand) throws Throwable {
..
..
}
的链接
请告知,如何解决此问题&重用现有的步骤?
非常感谢
replace: {
dist: {
options: {
patterns: [
{
match: /src="scripts/g,
replacement: 'src="{{STATIC_URL}}scripts'
},
{
match: /href="styles/g,
replacement: 'href="{{STATIC_URL}}styles'
}
]
},
files: [
{
expand: true,
flatten: true,
src: [
'<%= yeoman.dist %>/index.html',
],
dest: '<%= yeoman.dist %>'
}
]
}
}
答案 0 :(得分:0)
如果你想为And和When重用它,最简单的方法就是从两种方法中调用相同的逻辑:
@When("^User sends the command \"([^\"]*)\"$")
public void User_sends_the_command(String sUserCommand) throws Throwable {
doLogic(sUserCommand);
}
@And("^User sends SMS \"([^\"]*)\"$")
public void user_sends_sms(String sms) throws Throwable {
doLogic(sms);
}
如果你想在另一个(或和)中重复使用When(或And),你可以将它与regexp匹配,例如:
@And("^User sends (?:SMS|the command) \"([^\"]*)\"$")
public void User_sends_the_command(String sUserCommand) throws Throwable {
..
..
}
将匹配“用户发送短信abcd”和“用户发送命令efgh”