2016-01-12 45 views
0

我正在寫黃瓜測試,指定某些數字應該在數據的某些地方作爲字符串。所以我想這條命令:將黃瓜特徵文件中的數字包含爲字符串?

myFeature.feature

... 
Then this segment should equal 01 

mySteps.java

@Then("^Then this segment should equal 01$") 
public void myThenStep() { 
    // Do stuff 
} 

但是黃瓜告訴我用的就是這個:

@Then("^Then this segment should equal (\\d+)$") 
public void myThenStep(int arg1) { 
    // Do stuff 
} 

我不想包含參數,我試圖斷言我得到的字符串等於01.我該怎麼做?這似乎很簡單,但我找不到一個方法來逃避這個數字。謝謝!

回答

1

如果你不想從功能在01傳遞給你的腳步,而是把它作爲測試,這應該工作

@Then("^Then this segment should equal 01$") 
public void myThenStep() { 
    // Do stuff 
} 

如果你想在字符串中傳遞從您的特性文件,你可以做點像

@Then("^Then this segment should equal (.*)$") 
public void myThenStep(String arg1) { 
    // arg1 will be "01" in your test 
    // Do stuff 
} 
相關問題