behavior driven development using visual studio 2010 and specflow n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Behavior Driven Development Using Visual Studio 2010 And SpecFlow PowerPoint Presentation
Download Presentation
Behavior Driven Development Using Visual Studio 2010 And SpecFlow

Loading in 2 Seconds...

play fullscreen
1 / 16

Behavior Driven Development Using Visual Studio 2010 And SpecFlow - PowerPoint PPT Presentation


  • 112 Views
  • Uploaded on

Behavior Driven Development Using Visual Studio 2010 And SpecFlow. Ivan Pavlovi ć, Hive Studios Visual C# MVP, MCT , CSM paki@hive-studios.com http://msforge.net/blogs/paki http://twitter.com/ipavlovi. Agenda. Little bit of s lides , a lot of examples What is BDD Language Tools

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Behavior Driven Development Using Visual Studio 2010 And SpecFlow' - olive


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
behavior driven development using visual studio 2010 and specflow

Behavior Driven DevelopmentUsing Visual Studio 2010 AndSpecFlow

Ivan Pavlović, Hive Studios

Visual C# MVP, MCT, CSM

paki@hive-studios.com

http://msforge.net/blogs/paki

http://twitter.com/ipavlovi

agenda
Agenda
  • Little bit of slides, a lot of examples
  • What is BDD
  • Language
  • Tools
  • Demos
types of test
Types of Test
  • Unit testing
  • Acceptance / Customer testing
  • Integration testing
  • Performance testing
  • Regression testing
b ehaviour d riven d evelopment
BehaviourDrivenDevelopment
  • One of agile development techniques
  • Specification driven by examples
  • Clear communication between domain experts, developers, testers and customers

BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. - Dan North (http://dannorth.net/)

gherkin
Gherkin
  • DomainSpecificLanguage
  • Easy to understand by customers
  • Simple sintax, few keywords
    • Feature
    • Background
    • Scenario, Scenario Outline
    • Given,When, Then
  • Localized on 35+ languages
example
Example

1: Feature: Some descriptive text of what is desired

2: In order to realize a named business value

3: As an explicit system actor

4: I want to gain some beneficial outcome which furthers the goal

5:

6: Scenario: Some determinable business situation

7: Given some precondition

8: And some other precondition

9: When some action by the actor

10: And some other action

11: And yet another action

12: Then some testable outcome is achieved

13: And something else we can check happens too

14:

15: Scenario: A different situation

16: ...

real example
Real example

Feature: Serve coffee

In order to earn money

Customers should be able to

buy coffee at all times

Scenario: Buy last coffee

Given there are 1 coffees left in the machine

And I have deposited 1$

When I press the coffee button

Then I should be served a coffee

tools
Tools
  • Tools are generating *.feature files
  • Cucumber – Ruby, http://cukes.info/
  • SpecFlow– .NET, http://specflow.org
    • Nunit, MSTest, MBUnit…
  • …a lot of other tools
putting all the pieces together
Putting All The Pieces Together
  • User writes features & scenarios, clarify
  • SpecFlow generates one test per scenario
  • Developer runs test
  • Developer implements missing steps
  • Developer writes production code
  • Move to the next scenario
mapping step definitions
Mapping Step Definitions

7: Given some precondition

8: And some other precondition

9: When some action by the actor

10: Thensome testable outcome is achieved

[Given(@„some precondition")]

public void SomePrecondition() { … do something… }

[Given(@„some other precondition")]

public void SomePrecondition() { … do something… }

[When(@„some action by the actor")]

public void SomePrecondition() { … do something… }

[Then(@”some verifiable result”)]

Public void VerifyResult() { … do assert… }

Test Run

step arguments regex
Step Arguments - RegEx

7: GivenI have 5 apples

8: AndI eat 2 of them

9: Whensomeone asks how many apples I do have

10: Then I should answer “3 apples”

[Given(@„I have (.*) apples")]

public void SomePrecondition(intnumberOfApples) { … do something… }

[Given(@„ I eat (.*) of them")]

public void SomePrecondition(intnumberOfEatenApples) { … do something… }

[When(@„ someone asks how many apples I do have")]

public void SomePrecondition() { … do something… }

[Then(@” I should answer \“(.*) apples\””)]

Public void VerifyResult(int expected) { … do assert of expected … }

table parameters
Table Parameters

Scenario: Posting a validentry

Given I am on the postingpage

And I havefilledout the form as follows

| Label | Value |

| Yourname | Jakob |

| Yourcomment | Das ist gut! |

When I click the buttonlabelled "Post"

Then I should be on the guestbookpage

Andthe guestbookentriesincludes the following

| Name | Comment | Posted date |

| Jakob | Das ist gut! | (within last minute) |

[Given(@"I havefilledout the form as follows")]

publicvoidFillFormAsFollows(TechTalk.SpecFlow.Tabletable) {

foreach(var row in table.Rows) { ….. Do something … }

}

scenario outline refactoring
Scenario outline - refactoring

Scenario: TC1 Add two numbers

Given I have entered 1 into the calculator

And I have entered 2 into the calculator

When I press add

Then the result should be 3 on the screen

Scenario: TC2 Add two numbers

Given I have entered 2 into the calculator

And I have entered 2 into the calculator

When I press add

Then the result should be 4 on the screen

scenario outline refactoring1
Scenario outline - refactoring

Scenario Outline: TC5Given I have entered <x> into the calculatorAnd I have entered <y> into the calculatorWhen I press addThen the result should be <result> on the screenScenarios: addition| x | y | result|| 1 | 2 | 3 || 2 | 2 | 4 |

| 3 | -3 | 0 |

how to implement step definitions
How to Implement Step Definitions?
  • It’s up to you!
  • What you are testing?
    • PublicInterfaces / Components
    • WebUIusingbrowserautomation
      • WatiN, Selenium
    • WebUIusingRequest/Respons
      • Http Get/Post
    • Win UI usingautomation
      • White / Windows UI Automation
resources
Resources
  • Specflow
    • http://specflow.org
  • Gherkin
    • https://github.com/aslakhellesoy/cucumber/wiki/gherkin
  • White
    • http://white.codeplex.com/
  • WatiN
    • http://watiN.sourceforge.net