第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在特征文件中使用變量

如何在特征文件中使用變量

C#
ibeautiful 2023-12-17 10:44:50
如何在功能文件中使用變量?具體來(lái)說(shuō),我需要使用dateTime.now。理想情況下,類(lèi)似...Given the API returns items for "dateTime.now"when my function is run then I want that data in my database在我的驗(yàn)收測(cè)試文件中......[Given("The API returns line items for (.*)")]這是解決此問(wèn)題的正確方法嗎?我不確定如何在我的功能文件中使用變量。我希望我的驗(yàn)收測(cè)試使用當(dāng)前日期。
查看完整描述

2 回答

?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

最簡(jiǎn)單的方法是編寫(xiě)一個(gè)特定于“立即”返回行項(xiàng)目的步驟:


Given the API returns items for right now

您可以從新版本調(diào)用該步驟的其他版本:


[Given(@"the API returns items for right now")]

public void GivenTheAPIReturnsItemsForRightNow()

{

    GivenTheAPIReturnsItemsFor(DateTime.Now);

}

這避免了步驟之間的代碼重復(fù)。


查看完整回答
反對(duì) 回復(fù) 2023-12-17
?
楊魅力

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超6個(gè)贊

由于功能文件是您可以與業(yè)務(wù)利益相關(guān)者(或組織中的其他非 IT 人員)共享的內(nèi)容,因此使用“現(xiàn)實(shí)世界”功能文件會(huì)更有意義。功能文件中的語(yǔ)言。 此外,當(dāng)您在測(cè)試結(jié)束時(shí)將其傳遞給報(bào)告工具時(shí),它會(huì)更具可讀性。


我會(huì)這樣處理。 switch 語(yǔ)句可以輕松地使用現(xiàn)實(shí)世界語(yǔ)言添加其他類(lèi)型的日期:


[Given("The API returns line items for '(.*)'")]

public void GivenTheAPIReturnsItemsForTime(string mydate)

{

? ? ?switch (mydate)

? ? ?{

? ? ? ? ? case:"the current date":

? ? ? ? ? ? ? HandleApiDateTime(DateTime.Now.ToString("dd-MM-yyyy"))

? ? ? ? ? ? ? // pass the current date to the Api handler

? ? ? ? ? ? ? break;

? ? ? ? ? case:"yesterday":

? ? ? ? ? ? ? HandleApiDateTime(DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy"))

? ? ? ? ? ? ? // pass yesterdays date to the Api handler

? ? ? ? ? ? ? break;

? ? ? ? ? default:

? ? ? ? ? ? ? Console.Writeline("I didnt recognize this command");

? ? ? ? ? ? ? // or other error handling

? ? ? ? ? ? ? break;

? ? ?}

}


private void HandleApiDateTime(DateTime mydate)

{

? ? // do your api magic with a date object

}

你的功能文件可能看起來(lái)像


Given the API returns items for 'yesterday'

when my function is run?

then I want that data in my database


查看完整回答
反對(duì) 回復(fù) 2023-12-17
  • 2 回答
  • 0 關(guān)注
  • 187 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)