2014-01-28 26 views
0

问题可能听起来很新手。但在这里,我每次尝试在我的黄瓜功能文件中编写iphone5时,它会对参数5进行参数化。我不希望发生这种情况,并希望它将iphone5视为字符串。在黄瓜功能文件中指定一个数字

在我的特征文件中的行导致这就是: 然后上传iPhone5的图像“xxxx.png”

然后得到以下步骤定义:

@And("^then upload iPhone(\\d+) image \"([^\"]*)\"$") 
public void then_upload_iPhone_image(int arg1, String arg2) throws Throwable { 
    // Express the Regexp above with the code you wish you had 
    throw new PendingException(); 
} 

回答

1

只需卸下正则表达式的数字和删除该方法的参数。

@Given("^I upload to iphone5$") 
public void I_upload_to_iphone() throws Throwable { 
    // Express the Regexp above with the code you wish you had 
    throw new PendingException(); 
} 
你的情况

@And("^then upload iPhone5 image \"([^\"]*)\"$") 
public void then_upload_iPhone_image(String arg2) throws Throwable { 
    // Express the Regexp above with the code you wish you had 
    throw new PendingException(); 
}