在實際測試場景中,咱們頗有可能針對同一場景,有多組參數,這個時候使用在story中使用表格形式的參數,將簡化story的編寫。html
好比登錄,咱們的系統有5種角色的帳戶,咱們要執行相應的測試,那麼咱們的story多是像這個樣子的:java
若是角色再來幾個,story就會很長,變得比較難維護。測試
這個時候,咱們使用story的表格形式參數的特性,簡化story的編寫:ui
最後的story以下:this
相應的step代碼作一些改動url
一、Given註解的value內容和story中的given內容相同excel
二、相應的參數取值增長@Named註解code
@Given("current user uid is [uid] and password is [password]") public void init(@Named("uid") String uid, @Named("password")String password) { System.out.println("init: uid:" + uid + ",password:" + password); this.uid = uid; this.password = password; }
高級寫法:htm
咱們甚至能夠寫出相似excel中合併單元格參數形式,在一個表格中內嵌另一個表格:it
Given that Larry has done <trades> trades Then the traders activity is: |name|trades| |Larry|<trades>| |Moe|1000| |Curly|2000| Examples: |<trades>| |3000| |5000|