Acceptance Test - Business Readable Acceptance Test using - Specflow

Agendac#

  • Benefits
  • Living document
  • Frameworks specflow supports
  • How to integrate it in development cycles
  • Specflow technical features

Benefit -app

  1.                 Provide business readable test cases that can be executed and confirm by product to build confidence that development implemented exactly what business needed(build the right stuffs and built it right).
  2.                Giving up using the documenting test cases like traditional plain text that become stale after times, write it in Specflow framework can be well organized and update in time and versioning together with production code. 
  3.                 Ramp up new developer tester quicker by having them understand the test name, test step and related code.

Frameworks specflow supports ide

  1.   Unit Test, Integration Test, API and UI test

Specflow technical featuresui

  1.  Feature file Structure

tags can be at feature level or scenario level to indicate special attributes, using symbol @spa

    Header - Provide the feature name (Pretty much like a user story caption)code

          Scenrio 1 - Provide the scenarioci

                comment can be added at anywhere start with # to add remarkrem

               Step 1 - Logical step (Using Given, When, Then, And / But is key word that help improve the readibility)get

       All are in business languageinput

     2. Map the feature file to csharp class and method code

              using attributes [given] to map the code back to steps

              download specflow extension(generate mapping c# code, Tools->Extension and Updates->Search Specflow Visual Studio Extension), nuget packages(framework that glue the feature with IDE Xunit.Runner.VisualStudio ), nuget test frameworks(Specflow.Xunit nuget)

     3. Use scenario outline to organize parameterized inputs and outputs

Scenario Outline: Add numbers    

Given I have a new calculator start with <current>  

When I have entered <add> into the calculator  

Then the result should be <result> on the screen

Examples:

| current | add | result |

| 100     | 20  | 120    |

| 200     | 30  | 230    |

| 234     | 22  | 11     |

 

namespace POC_LAB_Spec {    

[Binding]    

public class SpecFlowFeature1Steps    

{         Calculator _cal;        

[Given(@"I have a new calculator start with (.*)")]        

public void GivenIHaveANewCalculatorStartWithCurrent(int current)        

{             _cal = new Calculator();             _cal.Current = current;         }

 

 [When(@"I have entered (.*) into the calculator")]        

public void WhenIHaveEnteredAddIntoTheCalculator(int add)         {             _cal.Add(add);         }

 

 [Then(@"the result should be (.*) on the screen")]        

public void ThenTheResultShouldBeResultOnTheScreen(int result)         {             Assert.True(result == _cal.Current);         }

    } }

相關文章
相關標籤/搜索