I developed single test case using testcasesource. Already read data from excel and stored in array. Now I want to assign the array values for testcasesource dynamically.How can i do that? This is my code.
[TestFixture]
class testcases
{
static String[] inputdata= readdata("Inputdata.xls", "DATA", "TestCase1");
static object[] exceldata = { new object[] {inputdata} };
[SetUp]
public void Setup()
{
//setup code here
}
[Test]
[TestCaseSource("exceldata")]
public void Sample(String Username,String password,String FirstName)
{
// test code here
}
[TearDown]
public void TearDown()
{
tstlogic.driverquit();
}
}
I have 3 input values in inputdata array i need to assign these value for testcasesource. Can anyone help?
See the following line. It defines the wrong type. Unfortunately this is hard to see when object[]
is used.
static object[] exceldata = { new object[] {inputdata} };
// type is object[] of object[] of string[]
Should be:
static object[] exceldata = { inputdata };
// type is object[] of string[]