数据驱动测试在NUnit的? [英] Data-driven testing in NUnit?

查看:161
本文介绍了数据驱动测试在NUnit的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MSTest的,你可以这样做:

In MSTest you can do something like:

[TestMethod]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", 
            "testdata.csv", "testdata#csv", DataAccessMethod.Sequential)]
public void TestSomething()
{
    double column1 = Convert.ToDouble(TestContext.DataRow["column1"]);
    ...
    Assert.AreEqual(...);
}

什么是相当于code在NUnit的2.5?

What is the equivalent code in NUnit 2.5?

推荐答案

我会看着参数测试文档中的NUnit 2.5 ,看看你可以这样做,你在做什么存在。我不记得NUnit的有一个内置的CSV阅读属性驱动的参数测试。有可能是一个社区的插件某处虽然。

I would look at the parameterized tests documentation in NUnit 2.5 and see if you can do something like what you're doing there. I do not recall NUnit having a built-in CSV reading attribute to drive parameterized tests. There may be a community plug-in somewhere though.

我还应该指出的是,如果你只是在寻找非MS单元测试框架库,为您排忧解难,xUnit.net确实有这个功能。看看从本堂本博客帖子

I should also point out that if you are just looking for non-MS Unit Testing framework libraries to help you out, xUnit.net does have this functionality. Check out this blog post from Ben Hall

这篇关于数据驱动测试在NUnit的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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