Using TestCaseSource , you should be able to iterate over an array of values and call the necessary methods, for example:
[TestFixture] public class TestClass { private Sut _sut; public TestClass() { _sut = new Sut(...); } private IEnumerable<object> TestCases { get { var values = new object[,] { { 1, "test", 3 }, { 2, "hello", 0 }, ... }; for (var i = 0; i < values.GetLength(0); ++i) { yield return _sut.Method1((int)values[i,0]); yield return _sut.Method2((string)values[i,1]); yield return _sut.Method3((int)values[i,2]); } } } [TestCaseSource("TestCases")] public void Test(object val) { Assert.That(val, Is.Null); } }
Note that the _sut instance must be created in the TestClass constructor. It is not enough to initialize it in the [SetUp] or [TestFixtureSetUp] .
If you need different _sut instances for different method calls, you can create a collection of Sut instances in the constructor and access the corresponding Sut element in the for TestCases getter loop. In addition, you can even Sut over all Sut elements in getter ...
source share