Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically Generate Test Fixtures and Test Cases in NUnit using folder structures and XML Files
    text
    copied!<p>I am trying to generate tests dynamically based on the structure of folders that contain XML files. (The tests use the XML files to drive Selenium RC)</p> <p>So say for example I have 3 Folders which also contain sub folders (each of which contain the Data.xml file I use to drive selenium RC)</p> <pre><code>TestData TestFixtureOne TestCaseOne Data.xml TestCaseTwo Data.xml TestCaseThree Data.xml TestFixtureTwo TestCaseOne Data.xml TestCaseTwo Data.xml TestFixtureThree TestCaseOne Data.xml TestCaseTwo Data.xml TestCaseThree Data.xml TestCaseFour Data.xml TestCaseFive Data.xml </code></pre> <p>The code I currently have is like so</p> <pre><code>using System; using System.Text; using System.Threading; using NUnit.Framework; using System.Collections.Generic; using System.Collections; using System.Configuration; namespace NUnitIntegration { [TestFixture] class SeleniumTest { private static string testDirectory; public SeleniumTest() { testDirectory = ConfigurationManager.AppSettings["TestDirectory"]; // Let’s assume this value is “C:\TestData\” } [SetUp] public void init() { // Nothing needed as of yet } [Test, TestCaseSource("GetTestCases")] public void TestSource(string test) { System.Console.WriteLine("Successfully executed test for: " + test); } [TearDown] public void dispose() { // Nothing needed as of yet } private static string[] GetTestCases() { return getTests(); } private static string[] getTests() { return Directory.GetDirectories(testDirectory); } } } </code></pre> <p>But this will only bring me back the TestFixtureOne, TestFixtureTwo, and TestFixtureThree folders (see below) which is not what I am after. I was trying to make it flexible so that I can added more tests if needed (more TestFixtures and TestCases).</p> <p>[NUnit Test Tree] TestSource TestFixtureOne TestFixtureTwo TestFixtureThree</p> <p>I have searched quite relentlessly recently and came across these threads which helped me very much, but now I am stuck!</p> <p><a href="https://stackoverflow.com/questions/3557904/test-used-in-multiple-testfixtures">used in multiple [TestFixture]s</a> (And another thread where I got the above code from)</p> <p>Any help would be greatly appreciated,</p> <p>Regards</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload