Reputation: 609
I've recently moved from a Java-JUnit4-Webdriver environment to a C#-NUnit-Webdriver one.
In Eclipse, I could create test-suites quickly by copying test classes into a test-suite class, and after minimal formatting, run them as JUnit tests. The JUnit test-suites used the pattern below:
package com.example.testsuites;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import com.example.TestBase;
import com.example.Test1;
import com.example.Test2;
import com.example.Test3;
import com.example.Test12;
import com.example.Test303;
@RunWith(Suite.class)
@SuiteClasses({Test1.class,
Test2.class,
Test3.class,
Test12.class,
Test303.class,
})
public class ExampleTestSuite extends TestBase {
}
Is there an equivalent way to conveniently generate NUnit test-suite classes and then execute them in Visual Studio?
I've been reading the NUnit documentation but can find no obvious equivalent. I know that with the NUnit GUI you can select tests to run via check-boxes but this does not create a permanent test-suite. And that suites can be created by adding attributes/categories etc to individual tests but this doesn't appear as flexible as the method above.
Upvotes: 2
Views: 4074
Reputation: 10350
You can use NUnit Suite functionality:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
private class AllTests
{
[Suite]
public static IEnumerable Suite
{
get
{
ArrayList suite = new ArrayList();
suite.Add(typeof(OneTestCase));
suite.Add(typeof(AssemblyTests));
suite.Add(typeof(NoNamespaceTestFixture));
return suite;
}
}
}
}
However, Suites are currently not displayed in the NUnit GUI.
[Category]
attribute instead of
Suite functionality.Upvotes: 1