简体   繁体   English

如何在visual studio之外运行SpecFlow测试

[英]How can I run SpecFlow tests outside of visual studio

I have a suite of SpecFlow tests written in C# using MSTest as the framework. 我使用MSTest作为框架,用C#编写了一套SpecFlow测试。 I understand its possible to upload the DLL to MTM and run them through there. 我理解可以将DLL上传到MTM并在那里运行它们。

However I was wondering if it was possible for me to execute these tests outside of Visual Studio. 但是我想知道我是否可以在Visual Studio之外执行这些测试。 For example via a dashboard. 例如,通过仪表板。 I wouldn't want the results uploaded to MTM or TFS as we have a few projects that are not connected to them. 我不希望将结果上传到MTM或TFS,因为我们有一些没有连接到它们的项目。

My framework uploads results to a database so thats good enough for me in terms of logging. 我的框架将结果上传到数据库,因此在记录方面对我来说足够好。

I gather I would have to do something with the DLL thats generated from building the project that contains SpecFlow, but I want to avoid using reflection if at all possible. 我收集我将不得不对构建包含SpecFlow的项目生成的DLL做一些事情,但我想尽可能避免使用反射。

Does anyone have any ideas on how I could go about this? 有没有人对我如何做到这一点有任何想法?

Tests written using Specflow are simply tests in selected testing framework (MSTest in your case) so you can run them using test runner for that framework. 使用Specflow编写的测试只是在选定的测试框架(在您的情况下为MSTest)中进行测试,因此您可以使用该框架的测试运行器来运行它们。

In case of MSTest you can use MSTest.exe (located in Visual Studio directory, probably also part of TFS installation). 对于MSTest,您可以使用MSTest.exe(位于Visual Studio目录中,可能也是TFS安装的一部分)。 Take a look here http://msdn.microsoft.com/en-US/library/ms182489.aspx on how to run tests (easiest way is to use /testcontainer option). 看看http://msdn.microsoft.com/en-US/library/ms182489.aspx如何运行测试(最简单的方法是使用/ testcontainer选项)。

Please note that MSTest is not the best test framework and running outside of Visual Studio is not the same as running them inside of it. 请注意,MSTest不是最好的测试框架,在Visual Studio外部运行与在其中运行它们不同。 There are problems with config file and separate files needed by tests. 配置文件和测试所需的单独文件存在问题。 If you hit these problems, you can switch to other test framework (I use NUnit). 如果遇到这些问题,可以切换到其他测试框架(我使用NUnit)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM