GUI Automation With Gherkin and Specflow

When I first got introduced to Gherkin language for writing Acceptance Test Criteria’s, I liked the way it was written as from a Developers/testers point of view this was finite and if written properly can be very close to something known as “precise”.

When practicing BDD using the Gherkin language, I’ve observed that most teams target their automated test packs either around the business layer or services layer or components for testing the behavior of their software when practicing BDD. Therefore the tests which require GUI (or UI) interaction are either done manually or through some external tools.

In my opinion, for GUI automation, usage of any tool that can be wired-up with your acceptance criteria’s is more beneficial than those which can’t. I’d like to make maximum use of the acceptance criteria’s and not limit it to a mere document to create a common understanding of the customers requirement within the product development team.

I belong to the .Net community and therefore for practicing BDD I have been using Specflow and thought of extending it for GUI testing using Microsoft Coded UI Test(CUIT).

To demonstrate GUI automation using Specflow, I have chosen a “Calculator” as my feature with a story to test the basic mathematical operations using various scenarios.

Feature: Calculator
 In order to avoid silly mistakes
 As a math idiot
 I want to be told the sum of two numbers

@mytag
Scenario: Add two numbers
 Given I have entered 50 into the calculator
 And I press "Add"
 And I have entered 70 into the calculator
 When I press "Equals"
 Then the result should be 120 on the screen

The video in the below link shows the end result of combining CUIT with Specflow.

BDD in Action with Specflow and Microsoft CUIT

(If the link is not accessible, then it may be because of the restrictions of  your network, try accessing from your personal devices and if the problem persists, please do reach out to me)

Note: If you find the video a bit slow or dull, that’s my bad.

Advantages of using CUIT with Specflow

  • Acceptance Criteria’s become more than just a document circulating between the Product Development team.
  • Through automation, the acceptance criteria’s become one of the prime source of measure for “Definition of Done” for all types of stories.
  • An investment which would start giving returns from the next iteration of your agile development cycle.
  • Builds your regression pack and can be used in successive iterations for GUI tests too.

Set-up your projects for GUI automation with Specflow

If you would like to set-up your projects for the CUIT and Specflow, please use the following steps as guidelines

  • Create a new or open and existing Unit Test/Coded UI Test Project
  • Using Nuget Package Manage console download the following packages
          Install-Package Specflow
          Install-Package Specflow.CodedUI -Version 1.0.0.23
  • Check if you have references to the following libraries
    • Microsoft.VisualStudio.QualityTools.CodedUITestFramework
    • Microsoft.VisualStudio.QualityTools.Common
    • Microsoft.VisualStudio.QualityTools.UnitTestFramework
    • Microsoft.VisualStudio.TestTools.UITest.Common
    • Microsoft.VisualStudio.TestTools.UITest.Extension
    • Microsoft.VisualStudio.TestTools.UITest.ExtensionUtilities
    • Microsoft.VisualStudio.TestTools.UITesting
    • TechTalk.SpecFlow

With that I end my post here with some references for Microsofts CUIT and a disclaimer.

Please feel free to “like” or write back or comment on the post.

Disclaimer

The views, ideas, opinions and information compiled in this blog are completely mine and has absolutely nothing to do with any of my previous, current or future employers.

References

CUIT

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: