需要安装 的插件:
1.去ms marketspace 下载插件: url: https://marketplace.visualstudio.com/
说明: specflow 2017 or 2019 , 目前 2019 版本下载速度很慢,还是2017比较稳定
nuget package 需要安装的包及版本:
选择的框架:
- .net core 2.1 +
- 新建项目时, 选择 xUnit Test Project(.NET Core) ,
新建一个specflow test case:
- 选择 specflow feature file :
SpecFlowFeature1.feature 呈现出来的代码如下:
Feature: SpecFlowFeature1
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
When I press add
Then the result should be 120 on the screen
- 生成step :
右键选择 Generate Step Definitions
Given 后边字体是白色的,说明已经生成step, 未生成step 的 字体是 紫色的
在弹出框中选择Generate (可以点击 preview, 提前预知/查看下生成的代码是啥)
紫色的如下图:
- 如何生成 .feature.cs文件?
编译 build testproject, 即可 - 如何让 specflow case 出现在 test explore 中?
依旧编译 project , 就可出现 case 了 - 如何调试?
可以 将断点打在 .feature 文件中,也可打在 Steps.cs 文件中,但debug 过程很慢,耐心等待即可 - build 出现 error 怎么解决: 如下表:
- specflow 思想源自于哪?
A: cucomber of java