I am generating NUnit testcases based on the file names.
The directory looks like this:
Customer
CustomerTestCase1.xml
CustomerTestCase2.xml
Account
AccountTestCase1.xml
AccountTestCase2.xml
I am using TestCaseSource:
string[] list = Directory.GetFiles(path, "*", SearchOption.AllDirectories)
foreach (string file in list)
{
yield return new TestCaseData(file)
}
How do I introduce hierarchy into the generated testcases? I need them to be organized in groups according to folder structure, so I could tick "Account" and all the account testcases would be selected.
Charlie Poole @ NUnit-Discuss
Hi Andrey,
If that structure is dynamic, then there is little you can do. However, if the structure does not change, then you can simply code multiple fixtures, with tests that take data from different sources.
So you might have a Customer fixture, pulling test data from some particular source or sources, and an Account fixture pulling its data from other sources.
Put the common code for these fixtures into a base class so that you don't have to repeat the logic. In fact, it should be easy to refactor directly from what you have to use of a base class and then to create separate leaf classes for the tests you want to select separately.
Charlie
http://groups.google.com/group/nunit-discuss/browse_thread/thread/543102e801511c41