???????????
????Spec Flow???????????????????????????????????????????????????????????????????????NUnit??в????WatiN????????????????????????WatiN???????????WatiN??й??????????(????WaitN???)??
[Test]
public void SearchForWatiNOnGoogle()
{
using (var browser = new IE("http://www.google.com"))
{
browser.TextField(Find.ByName("q")).TypeText("WatiN");
browser.Button(Find.ByName("btnG")).Click();
Assert.IsTrue(browser.ContainsText("WatiN"));
}
}
??????????????????????IE????????Google??URL??????????????????????????????????Google??檔???????????“q”????????????????????????????????????????????????????“WatiN”?????????????????“btnG”?????????????????????????????????????????“WatiN”??????????????κε??????
???????????????????????????WatiN????????????????????????Щ???????????????????????????д??????????????????
??????????????????Visual Studio?????????????????μ?????????????????NUnit??WatiN??????????????DLL????????????????С??????NUnit????????????nunit.framework.dll???????????????????????WatiN????????????????DLL???????????????????Interop.SHDocVw.dll??WatiN.Core.dll??
??????????????????????NuGet???NUnit??WatiN???????????????????????????NuGet?????????????????????????С??????????????????????NuGe????????????????????????????
????????????????Spec Flow??????????????С???NUnit??WatiN???????????????а??Spec Flow??????????????Dll?????Spec Flow??????Щ???????????????????????????????????????????????????????????????????????????????????Щ??????????????????
??????????Spec Flow????鰲?????????Program Files?????????????DLL???????????????????????????????У?TechTalk.SpecFlow.dll??
??????????????????
????????????????д?????????????????????????????????????????????????????????????????????????????
????Features
???????е?????????????????????
????StepDefinitions
?????????????????趨?彫??????????????
????StepHelpers
????????Spec Flow???????
??????Features??????????????μ??????Login.feature??Spec Flow?????????????????????????????????????????????????????????????????????
????Feature: Login
????Feature??Gherkin???????????????????feature????г?????Σ?????????????e?????????????????????????????е??????????????????????????????????Gherkin?????????????????????????????????????????
????In order to realize a named business value
????As an explicit system actor
????I want to gain some beneficial outcome which furthers the goal
??????????????????????????????????????????????????????????????????????????????????????????????????????????е??????????????????е?“named business value”??????????????????“beneficial outcome”??????????????????ò???????????????????????????????????????????????????Σ??????д????
????Feature: Login
????Scenario: Logging in with valid credentials
??????Feature?????Scenario???Gherkin???????????????????????e?????????????Feature????????scenario?????????????????????????????????????scenario??????????????????????????????Ч????????????
??????д??????
?????????????
?????????????????????????д???????????????????????????????檔??????????????????????????????????????????????????????????????ζ?????????????????
?????????????scenario????????????????磺?????????????棩??????????????磺?????????????Gherkin?У???????????????Given????????????????????????When?????
Feature: Login
Scenario: Logging in with valid credentials
Given I am at the 'Login' page
When I fill in the following form
| field    | value    |
| Username | testuser |
| Password | testpass |
And I click the 'Login' button
Then I should be at the 'Home' page
????????????????????Spec Flow????????????б?廯?????????????????У????????????????????????????????е???н????????ж????????????????磬Password??field?????е????????testuser????value???????е????
???????????????And???????衣And?????????????????????????????????????????????????????????And????????Given???裬 ????ò??????????????Given???衣???????????У???And???豻?????When???衣When???費(fèi)????pre??post??????????scenario????????????????????С?
????????????????趨??
??????????????????Login???????壬?????????test runner????????????и????????е????????衣????????Login???????е?4???????????塣??????????????????Step???д???????????????????LoginSteps???????Spec Flow????????в??趨?壬????????????Binding???????Binding????????TechTalk.SpecFlow??????????????
using TechTalk.SpecFlow;
[Binding]
class LoginSteps
{
}