c# - 如何使用 vstest.console.exe 在 cmd 中运行 Specflow 功能/场景?
问题描述
我有一个定义为的功能文件
Feature: Portal Sign in
In order to login to my portal
As a User
I have input user id and password
Scenario: User Login
Given I have entered username and password
When The user clicks on Login button
Then logged in successfully pop up message should be displayed
我试过这个cmd:
vstest.console.exe tests.dll /TestCaseFilter:"FullyQualifiedName~PortalSigninFeature"
但对于给定的测试用例过滤器,它返回没有测试匹配。我错过了什么吗?
另外,您如何建议使用 cmd 运行场景?
编辑:
情况大纲如下
Scenario Outline: Multiple User Login
Given I have entered <username> and <password>
When The user clicks on Login button
Then logged in successfully pop up message should be displayed
Examples:
|username|password|
|User1 |pwd1 |
|User2 |pwd2 |
当我运行下面的 cmd
SpecRun.exe run D:\SpecFlow\bin\Debug\MySpecFlowTests.dll --filter testpath:"Scenario:Multiple+User+Login"
发现的测试显示为 0。
我应该更改任何内容以使其适用于场景大纲吗?
解决方案
当我从命令行在 jenkins 中运行它时,我得到了以下内容。我正在使用 SpecRun 作为跑步者。这确实需要一个 RunSettings 文件。
cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow" vstest.console.exe /settings:E\MyPath\To\RunSettings\ E:\MyPathTo\Test.dll /ResultsDirectory:E:\MyPath\ /TestCaseFilter: "(TestCategory=MyTag)"
我创建了一个名为 Jenkins 的文件夹,并且 RunSettings 和 .srprofile 都驻留在该文件夹中。
RunSettings 文件指向 .srprofile
<RunSettings>
<!-- Configurations for SpecFlow+ Runner -->
<SpecRun>
<Profile>Jenkins/MyTest.srprofile</Profile>
<GenerateSpecRunTrait>false</GenerateSpecRunTrait>
<GenerateFeatureTrait>false</GenerateFeatureTrait>
</SpecRun>
</RunSettings>
如果您使用 SpecRun 作为运行程序,您也可以从 cmd 行运行它。相应地更新运行器版本。
cd E:\Path\to\packages\SpecRun.Runner.3.3.*\tools\net461
SpecRun.exe run PathTo/My.srprofile --baseFolder E:\Path\To\bin\Debug --filter "@TagL" --log specrun.log
要按功能名称运行,您将使用:
SpecRun.exe run D:\Path\Jenkins\My.srprofile --baseFolder D:\Path\bin\Debug --filter testpath:"Feature:MyFeature*" --log specrun.log
通配符将匹配以“MyFeature”开头的任何内容。
https://docs.specflow.org/projects/specflow-runner/en/latest/Profile/Filter.html
推荐阅读
- python - 并行化只需要在每 X 次迭代中运行的慢速函数,以免降低循环速度
- matlab - 使用ode45后如何在matlab中查找矩阵错误?
- java - WeakHashMap 交换值和键 + 更好的竞争保护
- office-interop - Microsoft.Office.Core 在未引用的程序集中定义。您必须添加对装配办公室的引用,Version=15.0.0.0
- javascript - 如何使 Selenium Javascript“sendKeysWithEmojis”代码适应 Python
- elasticsearch - 弹性搜索嵌套代码中的 SortDescriptor 未返回预期结果
- azure - Azure 计算机视觉与 Azure Blob 存储
- flutter - 视频带宽溢出
- javascript - Echarts Datazoom 在几个图表中
- c# - 如何在 valuechanged 事件之前获取 NumericUpDown 的文本?