private TestSuite CreateSimpleSuite(string name) { TestSuite suite = new TestSuite(name); Assert.That( suite.TestCaseCount, Is.EqualTo( 0 ) ); suite.AddTest(new SimpleTestCase("One")); suite.AddTest(new SimpleTestCase("Two")); suite.AddTest(new SimpleTestCase("Three")); Assert.That( suite.TestCaseCount, Is.EqualTo( 3 ) ); return suite; }
private TestSuite CreateSimpleSuite(string name) { TestSuite suite = new TestSuite(name); Assert.That(suite.TestCaseCount, Is.EqualTo(0)); suite.AddTest(new TestCase("One", new SimpleTestCase())); suite.AddTest(new TestCase("Two", new SimpleTestCase())); suite.AddTest(new TestCase("Three", new SimpleTestCase())); Assert.That(suite.TestCaseCount, Is.EqualTo(3)); return(suite); }
public ITest ProcessAssemblies(string[] assemblies) { if (assemblies == null) { return(null); } ArrayList testList = new ArrayList(); foreach (string assembly in assemblies) { CollectAssemblyTests(testList, assembly); } if (testList.Count == 0) { return(null); } if (testList.Count == 1) { return((ITest)testList[0]); } TestSuite suite = new TestSuite(); foreach (ITest test in testList) { suite.AddTest(test); } return(suite); }
public static TestSuite Suite() { TestSuite fullSuite, suite; fullSuite = new TestSuite("System.Windows.Forms Assembly Tests"); suite = new TestSuite("CheckedListBox tests"); suite.AddTests(typeof(TestCheckedListBox)); fullSuite.AddTest(suite); suite = new TestSuite("StatusBar tests"); suite.AddTests(typeof(TestStatusBar)); fullSuite.AddTest(suite); return(fullSuite); }
public void CanAddTestsToSuite() { TestSuite suite = CreateSimpleSuite("my suite"); TestSuite suite2 = CreateSimpleSuite("suite two"); suite.AddTest(suite2); Assert.That(suite.TestCaseCount, Is.EqualTo(6)); }
public static TestSuite Suite() { TestSuite fullSuite, suite; fullSuite = new TestSuite("System Assembly Tests"); suite = new TestSuite("Uri Tests"); suite.AddTests(typeof(TestUri)); fullSuite.AddTest(suite); suite = new TestSuite("Network Tests"); suite.AddTests(typeof(TestIPAddress)); suite.AddTests(typeof(TestWebHeaderCollection)); suite.AddTest(SuiteDiagnostics.Suite()); fullSuite.AddTest(suite); return(fullSuite); }
public static void Main() { TestSuite suite = new TestSuite(); suite.AddTest(new ExampleUnitTest()); IList <TestResult> results = suite.RunTests(); System.Console.WriteLine(TestSuite.DisplayResults(results)); }
/// <summary> /// Loads a test suite containing multiple tests from an assembly /// </summary> /// <param name="tests">String array containing the names of the test classes to load</param> /// <returns>A suite containing all the tests</returns> public static ITest Load(Assembly assembly, string[] tests) { TestSuite suite = new TestSuite("Test Fixtures"); foreach (string name in tests) { suite.AddTest(TestLoader.Load(assembly, name)); } return(suite); }
public void ErrorsPropagateToSuiteAsFailures() { TestSuite suite = CreateSimpleSuite("my suite"); DummyTestCase dummy = new DummyTestCase(); suite.AddTest(new TestCase("TheTest", dummy)); dummy.simulateTestError = true; TestResult result = suite.Run(); Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure)); }
public static TestSuite Suite() { TestSuite fullSuite, suite; fullSuite = new TestSuite("JScript Tests"); #if CONFIG_EXTENDED_NUMERICS && CONFIG_REFLECTION suite = new TestSuite("Parser Tests"); suite.AddTests(typeof(TestScanner)); suite.AddTests(typeof(TestParser)); fullSuite.AddTest(suite); suite = new TestSuite("Engine Tests"); suite.AddTests(typeof(TestEngine)); fullSuite.AddTest(suite); suite = new TestSuite("Global Tests"); suite.AddTests(typeof(TestGlobal)); fullSuite.AddTest(suite); #endif return(fullSuite); }
public static TestSuite Suite() { TestSuite fullSuite, suite; fullSuite = new TestSuite("Basic Tests"); #if CONFIG_EXTENDED_NUMERICS suite = new TestSuite("String Tests"); suite.AddTests(typeof(TestString)); fullSuite.AddTest(suite); #endif return(fullSuite); }
public static TestSuite Suite() { TestSuite fullSuite, suite; fullSuite = new TestSuite("System.Xml Tests"); suite = new TestSuite("General Tests"); suite.AddTests(typeof(TestNameTable)); suite.AddTests(typeof(TestXmlConvert)); suite.AddTests(typeof(TestXmlException)); suite.AddTests(typeof(TestXmlNamespaceManager)); suite.AddTests(typeof(TestXmlParserContext)); fullSuite.AddTest(suite); suite = new TestSuite("Writer Tests"); suite.AddTests(typeof(TestXmlTextWriter)); fullSuite.AddTest(suite); suite = new TestSuite("Reader Tests"); suite.AddTests(typeof(TestXmlTextReader)); fullSuite.AddTest(suite); #if !ECMA_COMPAT suite = new TestSuite("Node Tests"); suite.AddTests(typeof(TestXmlAttribute)); suite.AddTests(typeof(TestXmlCDataSection)); suite.AddTests(typeof(TestXmlComment)); suite.AddTests(typeof(TestXmlDocument)); suite.AddTests(typeof(TestXmlDocumentFragment)); suite.AddTests(typeof(TestXmlDocumentType)); suite.AddTests(typeof(TestXmlElement)); suite.AddTests(typeof(TestXmlSignificantWhitespace)); suite.AddTests(typeof(TestXmlText)); suite.AddTests(typeof(TestXmlWhitespace)); fullSuite.AddTest(suite); #endif return fullSuite; }
/// <summary> /// Loads all the test fixtures in an assembly /// </summary> /// <param name="assembly">The assembly to be loaded</param> /// <returns>A Test containing all fixtures found</returns> public static ITest Load(Assembly assembly) { TestSuite suite = new TestSuite(assembly.GetName().Name); foreach (Type type in assembly.GetTypes()) { if (IsTestFixture(type)) { suite.AddTest(new TestSuite(type)); } } return(suite); }
/// <summary> /// Loads all the test fixtures in an assembly /// </summary> /// <param name="assembly">The assembly to be loaded</param> /// <returns>A Test containing all fixtures found</returns> public static ITest Load(Assembly assembly) { TestSuite suite = new TestSuite(assembly.GetName().Name); foreach (Type type in assembly.GetTypes()) { if (Reflect.HasAttribute(type, typeof(TestFixtureAttribute))) { suite.AddTest(new TestSuite(type)); } } return(suite); }
/// <summary> /// Create the test suite. /// </summary> private TestSuite GetTestSuite(Type type) { var suite = new TestSuite(); suite.Name = GetType().GetSimpleName(); MethodInfo localSetupMethod = null; MethodInfo localTeardownMethod = null; foreach (var method in type.GetMethods()) { if (GetCustomAttribute <SetUpAttribute>(method) == null) { continue; } localSetupMethod = method; break; } foreach (var method in type.GetMethods()) { if (GetCustomAttribute <TearDownAttribute>(method) == null) { continue; } localTeardownMethod = method; break; } foreach (var method in type.GetMethods()) { if (GetCustomAttribute <TestAttribute>(method) == null) { continue; } var instance = (NUnitTestCase)type.NewInstance(); instance.SetTestMethod(method, localSetupMethod, localTeardownMethod, this); suite.AddTest(instance); } return(suite); }
void Start() { suite = new TestSuite(); suite.AddTest(new GameplayTestSetUnitTest()); }
public static TestSuite Suite() { // Each namespace has a "SuiteXXX" class that defines // the tests in that namespace. See the subdirectories // for these classes when adding new tests. TestSuite suite = new TestSuite("Runtime Tests"); suite.AddTest(SuiteSystem.Suite()); suite.AddTest(SuiteCollections.Suite()); suite.AddTest(SuiteText.Suite()); suite.AddTest(SuiteCryptography.Suite()); suite.AddTest(SuiteThreading.Suite()); suite.AddTest(SuiteGlobalization.Suite()); suite.AddTest(SuiteInteropServices.Suite()); suite.AddTest(SuiteCompilerServices.Suite()); suite.AddTest(SuiteSerialization.Suite()); suite.AddTest(SuiteSecurity.Suite()); suite.AddTest(SuiteIO.Suite()); #if CONFIG_REFLECTION_EMIT suite.AddTest(SuiteEmit.Suite()); #endif // CONFIG_REFLECTION_EMIT suite.AddTest(SuiteReflection.Suite()); return(suite); }
// // Main //////////////////////////////////////////////////////////////////////////////// static void Main(string[] args) { SharedBase.Config.Headless = false; List <String> suitesToRun = new List <String>(); suitesToRun.Add("Search-Weather-In-Your-City"); // // Define Suites // List <TestSuite> testSuites = new List <TestSuite>(); // // Search Weather In Your City Test Suite // SearchWeatherInYourCity searchWeatherInYourCity = new SearchWeatherInYourCity(browser); TestSuite testSuite = new TestSuite(); testSuite.Name = "Search-Weather-In-Your-City"; testSuite.AddTest("Search Weather In Your Country", new TestDelegate(searchWeatherInYourCity.SearchWeatherInYourCountry)); testSuites.Add(testSuite); // // Run Suites // Boolean isFirstTestSuite = true; foreach (TestSuite ts in testSuites) { if (suitesToRun.Contains(ts.Name)) { if (isFirstTestSuite) { isFirstTestSuite = false; } else { SharedBase.Log(""); SharedBase.Log(""); SharedBase.Log(""); } RunTestSuite(ts); } else { SharedBase.Log("Skipped Test Suite: '" + ts.Name + "'", 0); } } // // Write Results // StringBuilder sb = new StringBuilder(); sb.Append("<html>"); sb.Append("<head>"); sb.Append("<title>Test Run Results</title>"); sb.Append("</head>"); sb.Append("<body style=\"font-family: Arial; font-size: 14px; padding: 32px;\">"); Int32 successful = 0; Int32 failed = 0; Int32 skipped = 0; foreach (TestSuite executedTestSuite in ExecutedTestSuites) { foreach (NamedTestDelegate test in executedTestSuite.NamedTestDelegates) { if (test.TestResult == TestResult.SUCCESS) { successful += 1; } else if (test.TestResult == TestResult.FAIL) { failed += 1; } else if (test.TestResult == TestResult.SKIPPED) { skipped += 1; } } } sb.Append("<h1>Test Run Report, Successful: " + successful + ", Skipped: " + skipped + ", Failed: " + failed + "</h1>"); foreach (TestSuite executedTestSuite in ExecutedTestSuites) { sb.Append("<h2>" + executedTestSuite.Name + "</h2>"); foreach (NamedTestDelegate test in executedTestSuite.NamedTestDelegates) { String color = COLOR_LIGHT_GREY_ON_WHITE; if (test.TestResult == TestResult.SUCCESS) { color = COLOR_GREEN; } else if (test.TestResult == TestResult.FAIL) { color = COLOR_RED; } else if (test.TestResult == TestResult.SKIPPED) { color = COLOR_ORANGE; } sb.Append("<div style=\"width: 16px; height: 16px; display: inline-block; vertical-align: middle; background-color: " + color + "; border-radius: 50%; margin-right: 8px;\"></div>"); sb.Append("<div style=\"display: inline-block; vertical-align: middle;\">" + test.Name + "</div>"); sb.Append("<br />"); if (test.Exception != null) { sb.Append("<div style=\"padding-left: 24px; color: #888888; padding-top: 8px; padding-bottom: 8px;\">"); sb.Append(SharedBase.FormatException(test.Exception).Replace("\n", "<br />")); sb.Append("</div>"); } if (test.Screenshot != "") { sb.Append("<div style=\"padding-left: 24px; padding-top: 8px; padding-bottom: 8px;\">"); sb.Append("<a href=\"" + test.Screenshot + "\"><img src=\"" + test.Screenshot + "\" width=\"192\" height=\"108\" style=\"border: 0px;\" /></a>"); sb.Append("</div>"); } } } sb.Append("</body>"); sb.Append("</html>"); System.IO.File.AppendAllText(TestBase.ProjectPath + "\\Logs\\Test Run Results " + TestBase.RunId + ".html", sb.ToString()); }