亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為兩個具有不同語句的 GIVEN 獲取多個匹配綁定

為兩個具有不同語句的 GIVEN 獲取多個匹配綁定

Go
慕虎7371278 2022-11-21 20:16:26
我在 Specflow 中編寫了兩個場景,一個用于 UI,另一個用于 API。場景和步驟定義如下:Scenario 1:@RegressionScenario Outline: Add Single New External UserGiven the <role> is logged on to the portal with <email> and <password>When the <role> clicks on profile avatarSomething....Scenario 2:@GetClientListScenario Outline: GET API response for fetching list of Clients matching  criteria entered in the Search Text fieldGiven the <endpoint>When I call Get methodSomething....Step Definitions:[Given(@"the (.*) is logged on to the portal with (.*) and (.*)")]public void GivenLoginToPortal(string role, string email, string password) {    //Something }[Given(@"the (.*)")]public void GivenTheEndpoint(string endpoint) {     Endpoint = endpoint; }在這里,當我導航到第一個場景中 Given 語句的步驟定義時,它顯示找到多個匹配綁定的警告......并且多個匹配綁定引用第二個 Given 語句的步驟定義。但我相信既然兩個 Given 語句都不同,那么為什么第一個 Given 會拋出多個匹配綁定?
查看完整描述

1 回答

?
慕運維8079593

TA貢獻1876條經驗 獲得超5個贊

作為 Given- 屬性參數的字符串是一個正則表達式。并且 (.*) 在 Regex 中是包羅萬象的。因此,以 開頭的每個步驟the都將匹配此綁定。

我建議您將 step 更改為 line the endpoint with name '(.*)'。

另外一個最佳做法是用單引號將您的參數括起來'。捕獲參數更容易,VS 擴展可以更好地建議綁定骨架代碼。


查看完整回答
反對 回復 2022-11-21
  • 1 回答
  • 0 關注
  • 84 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號