[C#.NET][SpecFlow] Use Scenario Outline to perform multiple verifications
Continued from the previous article, http://www.dotblogs.com.tw/yc421206/archive /2014/12/25/147796.aspx
Table is used to process collections
Scenario Outline calls the tested end multiple times, which is a bit like the drive test in MSTest
p>
How to use Scenario Outline
- Declare Scenario Outline:
- Use Example to define input data and expected data
- To use the Example field , The field name should add
, for example:
The example is as follows:
Scenario Outline: authentication
Given I enter
,
When I press Login Then the result should be
Examples: | UserId | Password | Result | | kobe | 12234 | false | | yao | 1234 | true | | jordan | 5566 | false |
https://dotblogsamples.codeplex.com/SourceControl/latest#Simple.SpecflowLogin/Simple.SpecflowLogin/Login.feature
When Scenario is declared as Outline, and the test manager will split a Scenario into the number defined by Examples
To debug the entire scenario, you can right click Debug SpecFlow Scenario, or Ctrl+R, Ctrl+A< /p>
SpecFlow program, there is nothing special about it
[Given(@"我入(.*),(.*)")]
public void Given I enter (string userId, string password)
{
var account = new Account() {UserId = userId, Password = password };
ScenarioContext.Current.Set(account, "account");
}
[When(@"我 Press Login")]
public void When I press Login()
{
var account = ScenarioContext.Current.Get
("account"); var actual = this ._security.IsVerify(account.UserId, account.Password); ScenarioContext.Current.Set
(actual, "actual"); } [Then(@"Result should be(.*)")] public void Then result should be (bool expected) {var actual = ScenarioContext.Current.Get
("actual"); Assert.AreEqual(expected, actual);}
The procedure is as follows:
https://dotblogsamples.codeplex.com/SourceControl/latest#Simple. SpecflowLogin/Simple.SpecflowLogin/LoginSteps.cs
However, the program under test is just a very simple logic
public bool IsVerify(string userId, string password)
{
return userId == "yao" && password == "1234";
}
The procedure is as follows:
https://dotblogsamples.codeplex.com/SourceControl/latest#Simple.SpecflowLogin/Simple.Utility/Security.cs
The article comes from: https://www.dotblogs.com.tw/yc421206/2014/12/25/unit_test_specflow_scenario_outline
Project location: https://dotblogsamples.codeplex.com /SourceControl/latest#Simple.SpecflowLogin/
If there is a fallacy, please let me know, and novices please bear with me when posting
p>
2010~2017 C# Fourth Season
Original: Large Column [C#.NET][SpecFlow] Use Scenario Outline to perform multiple verifications