<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=BDD</id>
		<title>BDD - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=BDD"/>
		<link rel="alternate" type="text/html" href="https://www.logicwiki.co.uk/index.php?title=BDD&amp;action=history"/>
		<updated>2026-05-15T15:02:26Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>https://www.logicwiki.co.uk/index.php?title=BDD&amp;diff=47&amp;oldid=prev</id>
		<title>Dt1nh6: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.logicwiki.co.uk/index.php?title=BDD&amp;diff=47&amp;oldid=prev"/>
				<updated>2016-05-09T13:27:17Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 13:27, 9 May 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Dt1nh6</name></author>	</entry>

	<entry>
		<id>https://www.logicwiki.co.uk/index.php?title=BDD&amp;diff=46&amp;oldid=prev</id>
		<title>Macrop at 19:52, 20 August 2014</title>
		<link rel="alternate" type="text/html" href="https://www.logicwiki.co.uk/index.php?title=BDD&amp;diff=46&amp;oldid=prev"/>
				<updated>2014-08-20T19:52:10Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Tests]]&lt;br /&gt;
[[Category:BDD]]&lt;br /&gt;
[[Category:Extreme Programming]]&lt;br /&gt;
[[Category:CSharp]]&lt;br /&gt;
[[Category:ASP.NET]]&lt;br /&gt;
&lt;br /&gt;
== Behaviour Driven Development ==&lt;br /&gt;
It's one step ahead of Test Driven Development. &lt;br /&gt;
[[File:Bdd.png|frameless|BDD]]&lt;br /&gt;
&lt;br /&gt;
=== Installation === &lt;br /&gt;
 PM&amp;gt;Install-Package SpecFlow&lt;br /&gt;
 PM&amp;gt;Install-Package SpecFlow.NUnit&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
AppFolder -&amp;gt; features -&amp;gt; step_definitions&lt;br /&gt;
You may find BDD implementation for .net in http://www.specflow.org/ &lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
 Feature: Sign up&lt;br /&gt;
  Sign up should be quick and friendly.&lt;br /&gt;
 &lt;br /&gt;
  Scenario: Successful sign up&lt;br /&gt;
    New users should get a confirmation email and be greeted&lt;br /&gt;
    personally by the site once signed in.&lt;br /&gt;
    Given I have chosen to sign up&lt;br /&gt;
    When I sign up with valid details&lt;br /&gt;
    Then I should receive a confirmation email&lt;br /&gt;
    And I should see a personalized greeting message&lt;br /&gt;
 &lt;br /&gt;
  Scenario: Duplicate email&lt;br /&gt;
    Where someone tries to create an account for an email address&lt;br /&gt;
    that already exists.&lt;br /&gt;
    Given I have chosen to sign up&lt;br /&gt;
    But I enter an email address that has already registered&lt;br /&gt;
    Then I should be told that the email is already registered&lt;br /&gt;
    And I should be offered the option to recover my password&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
* Create a new Project with C# Class Library and save it (‘SpecflowTest‘ in my example).&lt;br /&gt;
* Download and install NuGet Package Manager using Tools -&amp;gt; Extension Manager. Restart MS Visual Studio in order for the changes to take effect.&lt;br /&gt;
* Go to Package Manager Console install the latest version of Selenium WebDriver by running the command Install-Package Selenium.WebDriver -Version 2.20.0&lt;br /&gt;
* Install the latest version of Selenium WebDriver Support Classes by running the command Install-Package Selenium.Support&lt;br /&gt;
&lt;br /&gt;
* Download the latest NUnit framework from the site: http://www.nunit.org&lt;br /&gt;
* Install the NUnit software on your machine.&lt;br /&gt;
* In Visual Studio, Go to the Project -&amp;gt; Add Reference menu item.&lt;br /&gt;
* When the Add Reference dialog appears, click on ‘Browse‘ and navigate to C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\framework and select nunit.framework.dll.&lt;br /&gt;
&lt;br /&gt;
* Download the latest NUnit framework from the site: http://www.specflow.org/&lt;br /&gt;
* Install the SpecFlow software on your machine.&lt;br /&gt;
* In Visual Studio, Go to the Project -&amp;gt; Add Reference menu item.&lt;br /&gt;
* When the Add Reference dialog appears, click on ‘Browse‘ and navigate to C:\Program Files (x86)\TechTalk\SpecFlow and select TechTalk.SpecFlow.dll.&lt;br /&gt;
&lt;br /&gt;
Consider a sample user story:&lt;br /&gt;
&lt;br /&gt;
 As an end user,&lt;br /&gt;
 I would like to visit the google search page &lt;br /&gt;
 And then I would like to search an item so that&lt;br /&gt;
 I can view the search results&lt;br /&gt;
&lt;br /&gt;
Let me write a test scenario for the above story:&lt;br /&gt;
&lt;br /&gt;
 Given I am on the Google home page&lt;br /&gt;
 When I search for text selenium&lt;br /&gt;
 Then I should see the search results &lt;br /&gt;
&lt;br /&gt;
Creating a new SpecFlow feature file:&lt;br /&gt;
Context-click on the project name ‘SpecflowTest‘ in the Solution Explorer&lt;br /&gt;
Select Add -&amp;gt; New Item&lt;br /&gt;
Select the ‘SpecFlow Feature File‘ and save it as ‘GoogleSearch.feature‘&lt;br /&gt;
&lt;br /&gt;
Specflow creates a new file “GoogleSearch.feature” and a designer file “GoogleSearch.feature.cs“. The default content of the Specflow file is in the Gherkin format.&lt;br /&gt;
The default content of the file is as shown is below:&lt;br /&gt;
&lt;br /&gt;
 Feature: Addition&lt;br /&gt;
  In order to avoid silly mistakes&lt;br /&gt;
  As a math idiot&lt;br /&gt;
  I want to be told the sum of two numbers&lt;br /&gt;
&lt;br /&gt;
 @mytag&lt;br /&gt;
 Scenario: Add two numbers&lt;br /&gt;
  Given I have entered 50 into the calculator&lt;br /&gt;
  And I have entered 70 into the calculator&lt;br /&gt;
  When I press add&lt;br /&gt;
  Then the result should be 120 on the screen&lt;br /&gt;
&lt;br /&gt;
Change the contents of the file to the new scenario as below and the Specflow generates a feature file ‘GoogleSearch.feature.cs':&lt;br /&gt;
&lt;br /&gt;
 Feature: Google Search&lt;br /&gt;
  As an end user,&lt;br /&gt;
  I would like to visit the google search page&lt;br /&gt;
  And then I would like to search an item so that&lt;br /&gt;
  I can view the search results&lt;br /&gt;
&lt;br /&gt;
@mytag&lt;br /&gt;
Scenario: Google Search&lt;br /&gt;
 Given I am on the Google home page&lt;br /&gt;
 When I search for text selenium&lt;br /&gt;
 Then I should see the search results&lt;br /&gt;
&lt;br /&gt;
 * Creating a new SpecFlow Step Definition file:&lt;br /&gt;
 * Rename the class ‘Class1.cs‘ to ‘GoogleSearchStepDefinition.cs‘.&lt;br /&gt;
 * Context-click on the feature file ‘GoogleSearch.feature‘ and select …… System generates a specification file ‘…..’ as shown below.&lt;br /&gt;
&lt;br /&gt;
 * Debug the project. Go to Projects -&amp;gt; Project Properties (‘SpecflowTest Properties‘ in my example).&lt;br /&gt;
 * Click on the ‘Debug‘ tab and set the ‘Start external program‘ to the location of NUnit exe file (C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-x86.exe).&lt;br /&gt;
 * Build the solution, Go to ‘Build -&amp;gt; Build Solution‘ (hit the F6 key) in Visual Studio.&lt;br /&gt;
 * Execute the test, Go to ‘Debug -&amp;gt; Start Debugging‘ (hit the F5 key) in Visual Studio. Visual Studio invokes the NUnit application.&lt;br /&gt;
 * In NUnit, click on ‘File -&amp;gt; Open Project‘ and choose the location of the SpecflowTest.dll file.&lt;br /&gt;
 * In NUnit, click on the ‘Run‘ button to run the tests. Test shows Inconclusive result and the result is displayed in NUnit ‘Text Output’ tab.&lt;br /&gt;
 * Copy the contents of the NUnit  ‘Text Output‘ tab and paste it in the ‘GoogleSearchStepDefinition.cs‘ step definition file as shown below. The key point here is that the class needs to be annotated with the binding attribute and we can use the (.*) expression to represent variables coming from the feature file.&lt;br /&gt;
&lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Collections.Generic;&lt;br /&gt;
 using System.Linq;&lt;br /&gt;
 using System.Text;&lt;br /&gt;
 using TechTalk.SpecFlow;&lt;br /&gt;
 namespace SpecflowTest&lt;br /&gt;
 {&lt;br /&gt;
  [Binding]&lt;br /&gt;
  class GoogleSearchStepDefinition&lt;br /&gt;
   {&lt;br /&gt;
  &lt;br /&gt;
   [Given(@&amp;quot;I am on the Google home page&amp;quot;)]&lt;br /&gt;
   public void GivenIAmOnTheGoogleHomePage()&lt;br /&gt;
   {&lt;br /&gt;
   ScenarioContext.Current.Pending();&lt;br /&gt;
   }&lt;br /&gt;
  &lt;br /&gt;
   [When(@&amp;quot;I search for text (.*)&amp;quot;)]&lt;br /&gt;
   public void WhenISearchForATextSelenium()&lt;br /&gt;
   {&lt;br /&gt;
   ScenarioContext.Current.Pending();&lt;br /&gt;
   }&lt;br /&gt;
  &lt;br /&gt;
   [Then(@&amp;quot;I should see the search results&amp;quot;)]&lt;br /&gt;
   public void ThenIShouldSeeTheSearchResultsForSelenium()&lt;br /&gt;
   {&lt;br /&gt;
   ScenarioContext.Current.Pending();&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
'''Creating a Static Browser class for defining the browser selection:'''&lt;br /&gt;
 * This class is a static helper class for selecting the browser and Selenium has support for Internet Explorer, Firefox and Chrome.&lt;br /&gt;
 * Context-click on the project name ‘SpecflowTest‘ in the Solution Explorer and select Add -&amp;gt; New Item&lt;br /&gt;
 * Create a C# file with name ‘WebBrowser.cs‘.&lt;br /&gt;
 * Now, copy and paste the code below to the ‘WebBrowser.cs‘.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Collections.Generic;&lt;br /&gt;
 using System.Linq;&lt;br /&gt;
 using System.Text;&lt;br /&gt;
 using TechTalk.SpecFlow;&lt;br /&gt;
 using OpenQA.Selenium;&lt;br /&gt;
 using OpenQA.Selenium.IE;&lt;br /&gt;
 using OpenQA.Selenium.Firefox;&lt;br /&gt;
 using OpenQA.Selenium.Chrome;&lt;br /&gt;
 namespace SpecflowTest&lt;br /&gt;
 {&lt;br /&gt;
    [Binding]&lt;br /&gt;
    public class WebBrowser&lt;br /&gt;
    {&lt;br /&gt;
      public static IWebDriver Current&lt;br /&gt;
      {&lt;br /&gt;
        get&lt;br /&gt;
        {&lt;br /&gt;
           if (!ScenarioContext.Current.ContainsKey(&amp;quot;browser&amp;quot;))&lt;br /&gt;
           {&lt;br /&gt;
           //Select IE browser&lt;br /&gt;
           ScenarioContext.Current[&amp;quot;browser&amp;quot;] = new InternetExplorerDriver();&lt;br /&gt;
  &lt;br /&gt;
           //Select Firefox browser&lt;br /&gt;
           //ScenarioContext.Current[&amp;quot;browser&amp;quot;] = new FirefoxDriver();&lt;br /&gt;
  &lt;br /&gt;
           //Select Chrome browser&lt;br /&gt;
           //ScenarioContext.Current[&amp;quot;browser&amp;quot;] = new ChromeDriver();&lt;br /&gt;
           }&lt;br /&gt;
         return (IWebDriver)ScenarioContext.Current[&amp;quot;browser&amp;quot;];&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
  &lt;br /&gt;
     [AfterScenario]&lt;br /&gt;
     public static void Close()&lt;br /&gt;
     {&lt;br /&gt;
      if (ScenarioContext.Current.ContainsKey(&amp;quot;browser&amp;quot;))&lt;br /&gt;
       {&lt;br /&gt;
           Current.Dispose();&lt;br /&gt;
       }&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
'''Implementing the Steps:'''&lt;br /&gt;
&lt;br /&gt;
* Remove all the methods ‘ScenarioContext.Current.Pending()‘&lt;br /&gt;
* Now, copy and paste the code below to the ‘GoogleSearchStepDefinition.cs‘ as shown below.&lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Collections.Generic;&lt;br /&gt;
 using System.Linq;&lt;br /&gt;
 using System.Text;&lt;br /&gt;
 using TechTalk.SpecFlow;&lt;br /&gt;
 using NUnit.Framework;&lt;br /&gt;
 using OpenQA.Selenium;&lt;br /&gt;
 using OpenQA.Selenium.Firefox;&lt;br /&gt;
 using OpenQA.Selenium.Support.UI;&lt;br /&gt;
 namespace SpecflowTest&lt;br /&gt;
 {&lt;br /&gt;
  [Binding]&lt;br /&gt;
  public class StepDefinition1&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  [Given(@&amp;quot;I am on the Google home page&amp;quot;)]&lt;br /&gt;
  public void GivenIAmOnTheGoogleHomePage()&lt;br /&gt;
  {&lt;br /&gt;
  //Navigate to the site&lt;br /&gt;
  WebBrowser.Current.Navigate().GoToUrl(&amp;quot;http://www.google.com&amp;quot;);&lt;br /&gt;
  //Check that the Title is what we are expecting&lt;br /&gt;
  Assert.AreEqual(&amp;quot;Google&amp;quot;, WebBrowser.Current.Title);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  [When(@&amp;quot;I search for text (.*)&amp;quot;)]&lt;br /&gt;
  public void WhenISearchForATextSelenium(string keyword)&lt;br /&gt;
  {&lt;br /&gt;
  // Find the text input element by its name&lt;br /&gt;
  IWebElement query = WebBrowser.Current.FindElement(By.Name(&amp;quot;q&amp;quot;));&lt;br /&gt;
  // Input the search text&lt;br /&gt;
  query.SendKeys(keyword);&lt;br /&gt;
  // Now submit the form&lt;br /&gt;
  query.Submit();&lt;br /&gt;
  &lt;br /&gt;
   // Google's search is rendered dynamically with JavaScript.&lt;br /&gt;
   // Wait for the page to load, timeout after 5 seconds&lt;br /&gt;
   WebDriverWait wait = new WebDriverWait(WebBrowser.Current, TimeSpan.FromSeconds(5));&lt;br /&gt;
   IWebElement title = wait.Until&amp;lt;IWebElement&amp;gt;((d) =&amp;gt;&lt;br /&gt;
   {&lt;br /&gt;
   return d.FindElement(By.ClassName(&amp;quot;ab_button&amp;quot;));&lt;br /&gt;
   });&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  [Then(@&amp;quot;I should see the search results&amp;quot;)]&lt;br /&gt;
  public void ThenIShouldSeeTheSearchResultsForSelenium()&lt;br /&gt;
  {&lt;br /&gt;
  //Check that the Title is what we are expecting&lt;br /&gt;
  Assert.AreEqual(&amp;quot;selenium - Google Search&amp;quot;, WebBrowser.Current.Title);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
 }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
'''Executing the Tests:'''&lt;br /&gt;
* Build the solution, Go to ‘Build -&amp;gt; Build Solution‘ (hit the F6 key) in Visual Studio.&lt;br /&gt;
* Execute the test, Go to ‘Debug -&amp;gt; Start Debugging‘ (hit the F5 key) in Visual Studio. Visual Studio invokes the NUnit application.&lt;br /&gt;
* In NUnit, click on ‘File -&amp;gt; Open Project‘ and choose the location of the SpecflowTest.dll file.&lt;br /&gt;
* In NUnit, click on the ‘Run‘ button to run the tests. Test is executed using NUnit.&lt;/div&gt;</summary>
		<author><name>Macrop</name></author>	</entry>

	</feed>