问题描述
我已经使用C#编写了一个用于ranorex自动化的控制台应用程序.
I have programmed an console application with c# for ranorex automation.
在我已构建的exe中,我想手动启动specflow功能文件.
Within the exe i have build i would like to kick off the specflow feature files manually.
我相信我需要创建一个TestRunnerManager并触发运行.
I believe I need to create a TestRunnerManager and trigger the run.
任何人都可以帮忙吗?
推荐答案
此问题与我前段时间询问MsTest().
This question is similar in spirit to one I asked a while back about MsTest (How do you run SpecFlow scenarios from the command line using MSTest?).
请记住,SpecFlow功能文件成为C#类.功能文件中的方案成为测试方法.您可以使用nunit-console
命令行实用工具运行以下命令:
Remember that SpecFlow feature files become C# classes. Scenarios within a feature file become test methods. You can use the nunit-console
command line utility to run these:
nunit-console /fixture:Your.Test.Project Your.Test.Project.dll
应该在Your.Test.Project
名称空间中运行所有测试.
Which should run all the tests in the Your.Test.Project
namespace.
使用@CategoryName
注释方案时:
@Feature1
Scenario: Some cool feature
Given ...
您也应该能够从命令行运行这些代码:
You should be able to run those from the command line as well:
nunit-console /include:Feature1 Your.Test.Project.dll
注意:它来自NUnit的较早版本.当前文档: https://github.com/nunit/docs/wiki/Console -命令行
Note: This is from an older version of NUnit. Current documentation: https://github.com/nunit/docs/wiki/Console-Command-Line
我将MsTest与Specflow一起使用,因此我的示例可能不正确,但这应该使您走上正确的道路.只需查看.feature文件生成的*.feature.cs
文件,即可为您提供一些提示.
I use MsTest with Specflow, so my examples might not be correct, but this should put you on the right path. Just look at the *.feature.cs
files generated by the .feature file to give you some hints.
无需创建自己的控制台应用程序即可运行这些测试.最坏的情况是,创建批处理文件或PowerShell脚本以启动所需的测试.
No need to create your own console application to run these tests. Worst case scenario, create a batch file or PowerShell script to kick off the tests you want.
这篇关于控制台应用程序通过不使用ncode运行器的代码启动Specflow功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!