Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Automated Testing With SpecFlow

No description
by

Ged McDermott

on 17 September 2012

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Automated Testing With SpecFlow

Automated
Testing With
SpecFlow Current Solution Spreadsheets Business Users Can't Understand Them Results Aren't Published
Only Test Team Know What's Being Tested Requires Coordination For Testing New Functionality No Version Control Boring & Repetitive "Entering 25 Orders In XWorkflows Was The Highlight Of Bijo's Week" Automated Solution SpecFlow Scenarios Are Easy To Understand Scenario: Check entitlements for customer that does not exist
Given I am NOT an existing customer
When I check entitlements
Then I should receive a 404 error with the message "Customer not found" Everyone Can Instantly See If Code Has Passed Tests Tests Easy To Create In Notepad Scenarios Stored In GitHub Frees QA Team Up To Do More Ad Hoc Testing Version 1 Scenario: Check entitlements for customer that does not exist
Given I am NOT an existing customer
When I check entitlements
Then I should receive a 404 error with the message "Customer not found" Version 2 Scenario: Check entitlements for customer that does not exist
Given I am NOT an existing customer
When I check entitlements
Then I should receive a 400 error with the message "Customer not found" What Is SpecFlow? BDD Implementation Of What Is Behaviour Driven Development? What Have Cucumbers Got To Do With BDD? What's A .Net? How Does It Work? Learning SpecFlow SpecFlow Made Of Two Components Scenarios Steps Scenario: Check entitlements for customer that does not exist
Given I am NOT an existing customer
When I check entitlements
Then I should receive a 404 error with the message "Customer not found" Written By Anyone (QA, Product Owner, Developers) [Given(@"I am NOT an existing customer")]
public void GivenIAmNotAnExistingCustomer()
{
Customer.Id = InvalidCustomerId;
} Steps Only Written By Developers Understanding Scenarios Given - Starting Point For Test When - Trigger For Test Then - Expected Results Three Important Keywords - Given, When & Then And - Used To Chain Commands Together Links Statements Together And Given I want to know the price of Nature Chemistry
And I am in GBR Then the price should be £75
And the tax should be £7.50 Should Be Independent Statements And Not Be Dependent On Previous Statement Given I want to know the price of Nature Chemistry
And that price is greater than £75 Wrong Should Avoid Setting Up Tests Given Given I want to know the price of Nature Chemistry Given there is a journal called Nature Chemistry
And I want to know the price Rather Than Should Be As Succinct As Possible Given I have logged in Given I have loaded the home page
And my username is "Bob"
And my password is "Alice" Rather Than Is The Trigger For The Test To Be Executed When When I check the product service Given I want the price of Nature Then it should be £85 [Given(@"I want the price of Nature")]
public void GivenIWantThePriceOfNature()
{
//Magic code to get price of Nature
} Checks Results Are As Expected Then When I check the product service Given I want the price of Nature Then the price should be £85 [Then(@"the price should be £85")]
public void ThenThePriceShouldBe()
{
Assert.AreEqual(price, "£85");
} Advanced Specflow Statements Can Be Reused Using Wildcards Tables Can Be Used To Check Multiple Values At Once Used In Steps By Developers To Reuse Statements Wildcards When I check the product service Given I want the price of Nature Then the price should be £85 [Then(@"the price should be (.*)")]
public void ThenThePriceShouldBe(string price)
{
Assert.AreEqual(value, price);
} Should Be Kept In Mind When Writing Scenarios Given I want the price of Nature

Given I want the price of Eye

Given I want the price of Oncogene Rather Than Given I want the value of Nature

Given I want to know the price of Eye Used To Pass In A Large Amount Of Data Tables Given I want the price of Nature
And I am in GBR
When I call the product service
The following details should be returned
| Price | Tax | Currency |
| 75 | 7.5 | £ | Can Be Used With Given, When Or Then Given I want the price of a journal with details
| Name | Code | Country |
| Eye | EYE | GBR | Table Column Names Are Chosen By Person Writing Scenario How Are We Going To Use It? Combining Scenarios In A Feature A Feature Describes What The Scenarios Are Testing Features Given I want the price of Bee Sting Review
And I am in GBR
When I call the product service
Then I should receive a 404 error with the message "Bee String Review not found" Scenarios Are Combined Together To Make Features One Feature Is Written At The Top For .Net Feature : Product Errors
In order to know when something's gone wrong
As a user
I want errors to be returned when applicable Given I want the price of Nature Chemistry
And I am in ABC
When I call the product service
Then I should receive a 404 error with the message "Country ABC not found" Open
Ticket GitHub Build Write Scenario Write
Steps Example Workflow Product Owner has decided that product service should return a specific error if country is invalid Example of invalid country is INVALID Message shown should be : That country doesn't exist Open Ticket Write Scenario What is GitHub Web-based repository for storing files Allows different versions of same file to be stored Changes reviewed using Pull Requests Git is the technology, GitHub is the website GitHub & Branches Current development done on master Work specific to ticket done on branch Branches are merged in to master (or trunk) master OPSDEV-3500 Invalid country error Release 4.3.1 OPSDEV-3501 Exciting changes to Sales Ledger Using GitHub THIS WILL BE COVERED IN DEPTH IN THE WORKSHOP 3. Create feature file containing scenario 1. Make sure Git is installed on your machine 2. Create a branch to do your work 4. "Add" changes to Git commit 5. Commit changes 6. Create pull request ProductError.feature ProductErrorSteps.cs Feature : Product Errors
In order to know when something's gone wrong
As a user
I want errors to be returned when applicable

Scenario : Invalid country is supplied
Given I want to know the price of NATURE
And I am in GBRRR
When I call the product service
Then I should receive a 404 error with the message "That country doesn't exist" public class EntitlementSteps{
public string Journal { get; set; }
public string Country { get; set; }
public XElement Response { get; set; }
[Given(@"I want to know the price of (.*))")]
public void GivenIWantToKnowThePriceOfNature(string journal)
{
Journal = journal;
}
[When(@"I call the product service")]
public void WhenICallTheProductService()
{
rawResponse = GetRESTUrl(URL);
Response = XElement.Parse(rawResponse);
}
[Then(@"I should receive a (.*) error with the message (.*)")]
public void ThenIShouldReceiveAnErrorWithAMessage(string error, string message)
{
Assert.AreEqual(error, Response.GetError());
Assert.AreEqual(message, Response.GetMessage());
}
} GitHub Build Server SpecFlow.Feature SpecFlowSteps.cs TeamCity Tests Status Product : Country Error Product : Source Code Not Applicable Error Product : Source Code Expired Error Product : Source Code Not Valid Error Product : Invalid Product 1. Build Code 2. Build Database 3. Run Integration Tests Any Questions? BDD is TDD done with a specific mindset; testing the intent of the system rather than testing a particular piece of code.
Full transcript