网络上有很多关于如何使用SpecFlow,如何配置TFS来运行测试的文章,但是没有一篇文章包含所有方面。在本文中,我将告诉您如何使每个人都可以方便地运行和编辑SpecFlow脚本。
在削减的基础上,您将学习如何获得:
- 从TFS运行测试
- 自动脚本链接到TFS中的测试用例
- TFS中的测试案例的最新内容
- 测试人员能够在版本控制系统中直接编辑脚本
![](https://habrastorage.org/webt/qz/sv/xi/qzsvxitxpn7rxzl282pvbrviqry.jpeg)
背景
BDD . - TFS, , SpecFlow — TFS, -. .
:
- SpecFlow
- Azure DevOps Server (aka Team Foundation Server)
- SpecFlow TFS
1.
, . .
![](https://habrastorage.org/webt/it/lw/lp/itlwlpkbwdnda0hgckji7rvljpi.jpeg)
2.
— Visual Studio Test
![](https://habrastorage.org/webt/nr/8j/wn/nr8jwnhmsvcloslrw52inufzney.jpeg)
![](https://habrastorage.org/webt/fi/wd/0n/fiwd0nrffz6gcesf4h2azac5z2w.jpeg)
3.
, Visual Studio TFS -. , , , FeatureSync. — feature , API TFS .
FeatureSync
namespace feature :
#language:en
@Namespace:Application.Autotests
Feature: Log to application
*namespace .dll -
TFS id :
![](https://habrastorage.org/webt/ew/xk/xf/ewxkxfkxhw9k8vomrin-qtpxsji.jpeg)
@2124573 @posistive
Scenario: Successful authorization
Given I on authorization page
And I enter:
| Login | Password |
| user | pass |
When I press Login button
Then Browser redirect on Home page
FeatureSync:
FeatureSync.exe -f C:\FolderWithFeatures -s https://tfs.server.com/collection -t 6ppjfdysk-your-tfs-token-2d7sjwfbj7rzba
:
![](https://habrastorage.org/webt/cd/mi/qu/cdmiqutagbwkkom7u9nrpnyc_ei.jpeg)
SpecFlow Automation
![](https://habrastorage.org/webt/x6/jc/sd/x6jcsdlf7hh0btb4tpchw-z4qgu.jpeg)
![](https://habrastorage.org/webt/it/vv/_0/itvv_0zofxl5h7uhtr25jdvt41w.jpeg)
4. -
我们创建一个测试计划,在其中添加自动化案例,在设置中选择组装并发布
![](https://habrastorage.org/webt/ym/6u/tj/ym6utj0hu2omw2ku6vkkvhburzo.jpeg)
![](https://habrastorage.org/webt/-p/d-/8j/-pd-8jpje4i1jcmx0w_qoen1ra4.jpeg)
5.运行测试
我们在测试计划中选择必要的测试并运行。
![](https://habrastorage.org/webt/gp/vr/ej/gpvrejka58pq9kcub8b32vtejai.jpeg)
结论
此配置的优点:
- 任何测试人员都可以在Web版本控制表单中打开fetaure文件,对其进行编辑,并且更改将在组装后立即生效
- 您可以随时随时运行测试
- 透明的测试模型-我们始终知道我们启动的测试的功能。