Dynamically create tests in NUnit

I’ve found a way that fits my purposes

Have one test case, and mark it with the TestCaseSource attribute like so

[Test, TestCaseSource("GetTestCases")]
public void TestFile(string filename)
{
    //do test
}

Then write the GetTestCases to read all the file names in the directory

private static string[] GetTestCases()
{
    return GetAllFilesInCurrentDirectory();
}

Then when I start NUnit I get a list of the tests to be run (listed under TestFile).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)