与Visual Studio单元测试中的NUnit TestCaseSource类似 [英] Something similar to NUnit TestCaseSource in Visual Studio unit testing

查看:105
本文介绍了与Visual Studio单元测试中的NUnit TestCaseSource类似的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio单元测试中是否有类似于NUnit TestCaseSource属性的内容?我找到的最接近的解决方案是使用数据源.但是我不想将测试用例参数存储在数据源中.

Is there anything similar to NUnit TestCaseSource attribute in Visual Studio unit testing? The closest solution I found was to use a DataSource. But I don't want to store my test case parameters in a data source.

推荐答案

数据源是接受测试输入的一种方法.您可以将测试数据保存为多种文件格式(xml,xls或sql db)

Datasource is one option to take the test input. You can save your test data in many file format (xml, xls or in sql db)

但是,如果您不想存储测试数据,请在将要在任何测试用例之前执行的任何方法中使用TestInitialize()属性.通过这种方法将所有测试数据的运行时间保存在xml,xls或sql db中,然后使用数据源在测试用例中使用它.

But if you don't want to store your test data, then use TestInitialize() attribute in any method that will execute before any of your test cases. Save all your test data run time in xml,xls or in sql db through this method and then using datasource use it in your test cases.

这里是 msdn 链接用于VSTS单元测试.希望对您有帮助.

Here is msdn link for VSTS unit test. Hope this will help you.

这篇关于与Visual Studio单元测试中的NUnit TestCaseSource类似的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆