nunit/mbunit参数化设置

nunit/mbunit参数化设置,nunit,automated-tests,fixtures,mbunit,Nunit,Automated Tests,Fixtures,Mbunit,我想为测试的设置提供参数化数据。大概是这样的: [TestCase("1", "2") [TestCase("a", "b") public class TestFixture { [SetUp] public void SetUp(string x, string y) { Console.WriteLine("Setup with {0}, {1}", x, y); } [Test] public void Test() {.

我想为测试的设置提供参数化数据。大概是这样的:

[TestCase("1", "2")
[TestCase("a", "b")
public class TestFixture
{
    [SetUp]
    public void SetUp(string x, string y)
    {
        Console.WriteLine("Setup with {0}, {1}", x, y);
    }

    [Test]
    public void Test() {...}
}
但我只能设法将参数传递给测试用例本身

我更喜欢nunitmbunit的解决方案,但可以选择其他解决方案(尚未确定使用哪个测试框架)。这最终适用于一组Selenium系统测试,其中安装程序创建浏览器会话

[编辑] 使用NUnit,我可以实现以下目标:

[TestFixture("1", "2")]
[TestFixture("a", "b")]
public class Tests
{
    private string _x;
    private string _y;

    public Tests(string x, string y)
    {
        _x = x;
        _y = y;
    }

    [SetUp]
    public void SetUp()
    {
        Console.WriteLine("Setup with {0}, {1}", _x, _y);
    }

    [Test]
    public void Test()
    {

    }
}
[TestFixture("1", "2")]
[TestFixture("a", "b")]
public class Tests
{
    private string _x;
    private string _y;

    public Tests(string x, string y)
    {
        _x = x;
        _y = y;
    }

    [SetUp]
    public void SetUp()
    {
        Console.WriteLine("Setup with {0}, {1}", _x, _y);
    }

    [Test]
    public void Test()
    {

    }
}
[/编辑]


这似乎适合我的需要,但我将把问题留待几天,看看是否有其他建议。

使用NUnit,我可以实现这一点:

[TestFixture("1", "2")]
[TestFixture("a", "b")]
public class Tests
{
    private string _x;
    private string _y;

    public Tests(string x, string y)
    {
        _x = x;
        _y = y;
    }

    [SetUp]
    public void SetUp()
    {
        Console.WriteLine("Setup with {0}, {1}", _x, _y);
    }

    [Test]
    public void Test()
    {

    }
}
[TestFixture("1", "2")]
[TestFixture("a", "b")]
public class Tests
{
    private string _x;
    private string _y;

    public Tests(string x, string y)
    {
        _x = x;
        _y = y;
    }

    [SetUp]
    public void SetUp()
    {
        Console.WriteLine("Setup with {0}, {1}", _x, _y);
    }

    [Test]
    public void Test()
    {

    }
}