0

I am trying to upgrade from NUnit 2 to NUnit 3.

And I built a Data-Driven-Helper to read test case data from several type of data files.

I found that NUnit 3.2's TestCaseSource that can pass parameters can help improve my Data-Driven-Helper, however, the problem is it keeps tell me "Message: System.Reflection.TargetParameterCountException: Parameter count mismatch."

Here are test codes:

    static public IEnumerable GetCases(string a)
    {
        yield return new object[] { "1", 1 };
    }

    [TestCaseSource(typeof(BaseFixtureTest), "GetCases", new object[] {"a"})]
    public void someTest(string Path, int deg)
    {
        //*** some test logic
    }
LN.EXE
  • 59
  • 8
  • I tried the code you gave above and it works fine for me using the VS adapter. How are you running the code, or is there something missing? – Rob Prouse Mar 28 '16 at 18:46
  • Thank you very much! I didn't use the NUnit 3 test adapter, the old one instead. It works after I install it, however, there is a problem that the "current directory" changes. – LN.EXE Mar 28 '16 at 19:13
  • The name "BaseFixtureTest" suggests that you are inheriting the fixture from a base class. If so, could you enlarge the sample to show us what's where? I believe we made some recent unreleased fixes pertaining to inherited fixtures. – Charlie Mar 28 '16 at 19:14
  • Our comments crossed just now! As you found out, the old adapter doesn't run 3.0 tests at all and if it's particularly old (<2.0) it doesn't even give an intelligent message. Actually, the current directory no longer changes, as it did in NUnit 2. :-) If you want to use the directory of the test assembly, look at TestContext.TestDirectory. – Charlie Mar 28 '16 at 19:17
  • Thank you very much. I found AppDomain.CurrentDomain.BaseDirectory is very useful in my case since there are some Selenium modules that I don't want them to have dependency on NUnit module. Anyway it works. Thanks again. – LN.EXE Mar 29 '16 at 13:36

0 Answers0