Console Application to launch Specflow features by code not using ncode runner

眉间皱痕 提交于 2019-12-11 06:19:19

问题


I have programmed an console application with c# for ranorex automation.

Within the exe i have build i would like to kick off the specflow feature files manually.

I believe I need to create a TestRunnerManager and trigger the run.

Can anyone help?


回答1:


Although not familiar with nunit, I guess like with mstest, attributes are used to mark methods in an assembly as tests. You could use reflection to find these methods in the assembly and invoke them




回答2:


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?).

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

Which should run all the tests in the Your.Test.Project namespace.

When annotating scenarios using @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

Note: This is from an older version of NUnit. Current documentation: https://github.com/nunit/docs/wiki/Console-Command-Line


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.

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.



来源:https://stackoverflow.com/questions/42677788/console-application-to-launch-specflow-features-by-code-not-using-ncode-runner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!