使用 VS2010 测试工具进行参数化测试
是否可以使用 VS2010 Silverlight 测试工具编写参数化测试?
在常规 NUnit 测试中,这可以使用 TestCase 属性来完成...
[Test]
[TestCase("myParam1")]
[TestCase("myParam2")]
[TestCase("myParam3")]
public void TestSomethingWithParameters(string myParam)
{
// ...some tests using myParam
}
这可以使用 VS2010 测试工具吗?
Is it possible to write parameterized tests using VS2010 Test Tools for Silverlight?
In a regular NUnit test this would be done using TestCase attributes...
[Test]
[TestCase("myParam1")]
[TestCase("myParam2")]
[TestCase("myParam3")]
public void TestSomethingWithParameters(string myParam)
{
// ...some tests using myParam
}
Is this possible using VS2010 Test Tools?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,这是不可能的。下一个最好的办法是使用数据驱动测试,例如
http: //callumhibbert.blogspot.com/2009/07/data-driven-tests-with-mstest.html
查看 MSDN 文档。
No, this is not possible. The next best thing is to use data driven tests e.g.
http://callumhibbert.blogspot.com/2009/07/data-driven-tests-with-mstest.html
Check out the MSDN documentation also.
您可以创建一个基类,其中包含测试方法和参数作为虚拟属性。
当您从此类继承时,您只需使用所需的值覆盖属性。
请看示例代码:
You can create a base class with the test method and the parameters as virtual properties.
When you inherit from this class you only need to override the properties with the desired values.
Please see the sample code: