c# - wrong number of arguments provided in nunit -
developed testcase testcasesource in selenium using c#. after running test case in nunit, shows error "wrong number of arguments provided". , test case code
[testfixture] class testcases { static string[] exceldata= readdata("inputdata.xls", "data", "testcase1"); [setup] public void setup() { //setupcode here } [test, testcasesource("exceldata")] public void sample (string level,string username,string password,string firstname) { //testcase code here } [teardown] public void teardown() { tstlogic.driverquit(); }
the 4 values retrieved , can see values in nunit. shows error "wrong number of arguments provided". can anyaone please help?
the method marked testcasesource supposed return bunch of "testcases" - each testcase set of inputs required test method. each test-input-set in case must have 4 string params.
so testcasesource method should returning object[] contains internal 4 member arrays. see following example
[test, testcasesource("dividecases")] public void dividetest(int n, int d, int q) { assert.areequal( q, n / d ); } static object[] dividecases = { new object[] { 12, 3, 4 }, new object[] { 12, 2, 6 }, new object[] { 12, 4, 3 } };
in case, think testcasesource method returning 4 strings. nunit reads 4 input-param-sets.. each containing 1 string. attempting call parameterized test method 4 params 1 string => error seeing.
e.g. can reproduce error setting dividecases this
private static int[] dividecases = new int[] { 12, 3, 4 }; // wrong. blow
Comments
Post a Comment