zoukankan      html  css  js  c++  java
  • SpecFlow used in visual studio

    https://docs.specflow.org/projects/getting-started/en/latest/GettingStarted/Step1.html

    https://docs.specflow.org/projects/getting-started/en/latest/GettingStarted/Step2.html

    https://docs.specflow.org/projects/getting-started/en/latest/GettingStarted/Step3.html

    Create SpecFlow project - Continue  step4 

    SpecFlow + Runner activation  step5

    Bind the first step  step6

    The purpose of this feature file is to document the expected behavior of the calculator in a way that it is both human-readable and suitable for test automation.

    SpecFlow uses the Gherkin language where you can phrase the scenarios using Given/When/Then steps.

    Currently there is a single scenario (automatically added by the SpecFlow project template) that describes how adding two numbers should work with the calculator.

    Here is a closer look at the Gherkin scenario used in this template:

    Scenario: Add two numbers
        Given the first number is 50
        And the second number is 70
        When the two numbers are added
        Then the result should be 120

    Based on the scenario text, SpecFlow generates an automated test that executes the scenario. However, it is not yet defined what the steps of the scenario should actually “do”.

    2- Right-click the first Given step “Given the first number is 50” and select either the “Go To Definition” or the “Go To Step Definition” command.

    Visual Studio locates the step definition (binding) that belongs to this step. In this example, it opens the CalculatorStepDefinitions class and jumps to the GivenTheFirstNumberIs method.

    *The step definition is located based on the [Binding] attribute on the class and the [Given] attribute on the method. The regular expression of the Given attribute matches the text of the scenario step.

    3- Add the below field to the class to instantiate the calculator that we want to test and created in Step 2 of this guide (SUT).

            private readonly Calculator _calculator = new Calculator();
    

    Add Living Documentation  step9

    2- Install the LivingDoc CLI as a global dotnet tool.

    dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI
    

    3- Navigate to the output directory of the SpecFlow project. In this example the solution was setup in the C:work folder.

    cd C:workSpecFlowCalculatorSpecFlowCalculator.SpecsinDebug
    etcoreapp3.1
    

    4- Run the LivingDoc CLI by using the below command to generate the HTML report.

    livingdoc test-assembly SpecFlowCalculator.Specs.dll -t TestExecution.json
    

    5- Open the generated HTML with your favorite browser. The HTML file is stored in the same folder as the output directory of the SpecFlow project.

    C:workSpecFlowCalculatorSpecFlowCalculator.SpecsinDebug
    etcoreapp3.1LivingDoc.html
    
  • 相关阅读:
    js问题记录
    css问题记录
    vscode配置java+gradle开发环境
    js插件
    nginx笔记
    vue刷新当前路由
    koa踩坑记录
    react踩坑笔记
    ts踩坑笔记
    vue源码阅读笔记
  • 原文地址:https://www.cnblogs.com/chucklu/p/14809920.html
Copyright © 2011-2022 走看看