[C # .NET] [SpecFlow] Execute multiple validations using SCENARIO OUTLINE

[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

  1. Declare Scenario Outline:
  2. Use Example to define input data and expected data
  3. 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

Share pictures

To debug the entire scenario, you can right click Debug SpecFlow Scenario, or Ctrl+R, Ctrl+A< /p>

share picture

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

share picture

 Share pictures 2010~2017 C# Fourth Season

Original: Large Column [C#.NET][SpecFlow] Use Scenario Outline to perform multiple verifications

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3087 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.