2013-02-15 66 views

回答

7

簡單(.+)應該工作

Given I have a floating point 1.2345 number 

@Given("^I have a floating point (.+) number$") 
public void I_have_a_floating_point_number(double arg) throws Throwable { 
    ... 
} 
0

你應該逃脫浮點數與(\\d+)

Given I have a floating point 1.2345 number 

@Given("^I have a floating point (\\d+) number$") 
public void I_have_a_floating_point(double arg){ 

} 
+0

這不是問題 – 2016-06-03 21:50:44

2

我用表格

@When("^We change the zone of the alert to \\(([0-9\\.]+),([0-9\\.]+)\\) with a radius of (\\d+) meters.$") 
public void we_change_the_zone_of_the_alert_to_with_a_radius_of_meters(double latitude, double longitude, int radius) 

所以[0-9.]+使交易:)

照顧你的黃瓜當地。例如,如果您使用的是language:fr,則編號使用,作爲分隔符。

+0

語言產生變化的事的情景!語言:de也是一樣。謝謝! – 2017-08-08 15:17:11

3

我自己的偏好是指定數字的其中任何一個點的邊,像...

@Given("^the floating point value of (\\d+.\\d+)$") 
public void theFloatingPointValueOf(double arg) { 
    // assert something 
} 

,正如你提到的浮點輸入多,我可能會像一個輪廓處理多個輸入.. 。

Scenario Outline: handling lots of floating point inputs 
    Given the floating point value of <floatingPoint> 
    When something happens 
    Then some outcome 

    Examples: 
     | floatingPoint | 
     | 2.0   | 
     | 2.4   | 
     | 5.8   | 
     | 3.2   | 

它將每運行浮點輸入