public void RunMockAssembly() { Test test = testDomain.Load("mock-assembly.dll"); TestResult result = testDomain.Run(NullListener.NULL); Assert.IsNotNull(result); }
public void AppDomainUnloadedBug() { TestDomain domain = new TestDomain(); domain.Load( new TestPackage( mockDll ) ); domain.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off); domain.Unload(); }
public void AppDomainUnloadedBug() { TestDomain domain = new TestDomain(); domain.Load( new TestPackage( "mock-assembly.dll" ) ); domain.Run(new NullListener()); domain.Unload(); }
public void AppDomainUnloadedBug() { TestDomain domain = new TestDomain(); domain.Load( new TestPackage( mockDll ) ); domain.Run(new NullListener()); domain.Unload(); }
public void ServerTimeoutTest() { // Delay after loading the test Thread.Sleep(timeout); // Copy all the tests from the remote domain // to verify that Test object is connected. UITestNode node = new UITestNode(test, true); // Run the tests, which also verifies that // RemoteTestRunner has not been disconnected TestResult result = domain.Run(NullListener.NULL); // Delay again to let the results "ripen" Thread.Sleep(timeout); // Visit the results of the test after another delay ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(5, summarizer.ResultCount); Assert.AreEqual(2, summarizer.TestsNotRun); // Make sure we can still access the tests // using the Test property of the result node = new UITestNode(result.Test, true); }
public void AppDomainUnloadedBug() { TestDomain domain = new TestDomain(); domain.Load(new TestPackage(mockDll)); domain.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off); domain.Unload(); }
public void AppDomainUnloadedBug() { TestDomain domain = new TestDomain(); domain.Load(new TestPackage(mockDll)); domain.Run(new NullListener()); domain.Unload(); }
public void RunMultipleAssemblies() { TestResult result = domain.Run(NullListener.NULL); ResultSummarizer summary = new ResultSummarizer(result); Assert.AreEqual( NoNamespaceTestFixture.Tests + MockAssembly.TestsRun, summary.TestsRun); }
public void AppDomainUnloadedBug() { TestDomain domain = new TestDomain(); domain.Load(new TestPackage("mock-assembly.dll")); domain.Run(new NullListener()); domain.Unload(); }
public void RunMultipleAssemblies() { TestResult result = domain.Run(NullListener.NULL, TestFilter.Empty, false, LoggingThreshold.Off); ResultSummarizer summary = new ResultSummarizer(result); Assert.AreEqual( NoNamespaceTestFixture.Tests + MockAssembly.TestsRun, summary.TestsRun); }
private TestResult RunTest(ConsoleWriter outStream, TestDomain testDomain) { EventListener collector = new EventCollector(outStream); ITestFilter filter = new NUnit.Core.Filters.SimpleNameFilter(mPNUnitTestInfo.TestToRun); TestResult result = FindResult( mPNUnitTestInfo.TestToRun, testDomain.Run(collector, filter, false, LoggingThreshold.Off)); return(result); }
public void CanRunMockAssemblyTests() { TestResult result = testDomain.Run(NullListener.NULL); Assert.IsNotNull(result); Assert.AreEqual(false, result.IsFailure, "Test run failed"); ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(MockAssembly.Tests - MockAssembly.NotRun, summarizer.ResultCount); Assert.AreEqual(MockAssembly.Ignored, summarizer.TestsNotRun); }
public void CanRunMockAssemblyTests() { TestResult result = testDomain.Run(NullListener.NULL); Assert.IsNotNull(result); ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(MockAssembly.TestsRun, summarizer.TestsRun, "TestsRun"); Assert.AreEqual(MockAssembly.Ignored, summarizer.Ignored, "Ignored"); Assert.AreEqual(MockAssembly.Errors, summarizer.Errors, "Errors"); Assert.AreEqual(MockAssembly.Failures, summarizer.Failures, "Failures"); }
public void ResultStillValidAfterDomainUnload() { TestPackage package = new TestPackage(mockDll); Assert.IsTrue(domain.Load(package)); TestResult result = domain.Run(new NullListener()); TestResult caseResult = findCaseResult(result); Assert.IsNotNull(caseResult); TestResultItem item = new TestResultItem(caseResult); string message = item.GetMessage(); Assert.IsNotNull(message); }
public void ResultStillValidAfterDomainUnload() { //TODO: This no longer appears to test anything TestPackage package = new TestPackage(mockDll); Assert.IsTrue(domain.Load(package)); TestResult result = domain.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off); TestResult caseResult = findCaseResult(result); Assert.IsNotNull(caseResult); //TestResultItem item = new TestResultItem(caseResult); //string message = item.GetMessage(); //Assert.IsNotNull(message); }
public void SpecificTestFixture() { TestPackage package = new TestPackage("mock-assembly.dll"); package.TestName = "NUnit.Tests.Assemblies.MockTestFixture"; testDomain.Load(package); TestResult result = testDomain.Run(NullListener.NULL); Assert.AreEqual(true, result.IsSuccess); ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(MockTestFixture.Tests - MockTestFixture.NotRun, summarizer.ResultCount); Assert.AreEqual(MockTestFixture.Ignored, summarizer.TestsNotRun); }
public void SpecificTestFixture() { TestPackage package = new TestPackage("mock-assembly.dll"); package.TestName = "NUnit.Tests.Assemblies.MockTestFixture"; testDomain.Load(package); TestResult result = testDomain.Run(NullListener.NULL); ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(MockTestFixture.TestsRun, summarizer.TestsRun, "TestsRun"); Assert.AreEqual(MockTestFixture.Ignored, summarizer.Ignored, "Ignored"); Assert.AreEqual(MockTestFixture.Errors, summarizer.Errors, "Errors"); Assert.AreEqual(MockTestFixture.Failures, summarizer.Failures, "Failures"); }
public void SpecificTestFixture() { TestPackage package = new TestPackage(mockDll); package.TestName = "NUnit.Tests.Assemblies.MockTestFixture"; testDomain.Load(package); TestResult result = testDomain.Run(NullListener.NULL, TestFilter.Empty, false, LoggingThreshold.Off); ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(MockTestFixture.TestsRun, summarizer.TestsRun, "TestsRun"); Assert.AreEqual(MockTestFixture.Ignored, summarizer.Ignored, "Ignored"); Assert.AreEqual(MockTestFixture.Errors, summarizer.Errors, "Errors"); Assert.AreEqual(MockTestFixture.Failures, summarizer.Failures, "Failures"); }
public TestResult Execute(string configFileName, ITestFilter filter) { if (ServiceManager.Services.GetService(typeof(DomainManager)) == null) { ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.InitializeServices(); } var package = new NBiPackage(BinPath, configFileName); var runner = new TestDomain(); runner.Load(package); var testResult = runner.Run(new NullListener(), filter, false, LoggingThreshold.Warn); return(testResult); }
public void ResultStillValidAfterDomainUnload() { TestPackage package = new TestPackage("mock-assembly.dll"); Assert.IsTrue(domain.Load(package)); TestResult result = domain.Run(new NullListener()); TestSuiteResult suite = result as TestSuiteResult; Assert.IsNotNull(suite); TestCaseResult caseResult = findCaseResult(suite); Assert.IsNotNull(caseResult); TestResultItem item = new TestResultItem(caseResult); string message = item.GetMessage(); Assert.IsNotNull(message); }
public static void Main(string[] args) { NUnitBridge listener = null; try { listener = new NUnitBridge(Int32.Parse(args[0])); TestDomain domain = new TestDomain(); domain.Load(args[1]); domain.Run(listener); listener.Close(); } finally { if (listener != null) { listener.Close(); } } }
public void ResultStillValidAfterDomainUnload() { TestDomain domain = new TestDomain(Console.Out, Console.Error); Test test = domain.Load("mock-assembly.dll"); Assert.IsNotNull(test); TestResult result = domain.Run(new NullListener()); TestSuiteResult suite = result as TestSuiteResult; Assert.IsNotNull(suite); TestCaseResult caseResult = findCaseResult(suite); Assert.IsNotNull(caseResult); TestResultItem item = new TestResultItem(caseResult); domain.Unload(); string message = item.GetMessage(); Assert.IsNotNull(message); }
public int Execute(ConsoleOptions options) { XmlTextReader transformReader = GetTransformReader(options); if (transformReader == null) { return(3); } ConsoleWriter outStream = options.isOut ? new ConsoleWriter(new StreamWriter(options.output)) : new ConsoleWriter(Console.Out); ConsoleWriter errorStream = options.isErr ? new ConsoleWriter(new StreamWriter(options.err)) : new ConsoleWriter(Console.Error); TestDomain testDomain = new TestDomain(outStream, errorStream); if (options.noshadow) { testDomain.ShadowCopyFiles = false; } Test test = MakeTestFromCommandLine(testDomain, options); if (test == null) { Console.Error.WriteLine("Unable to locate fixture {0}", options.fixture); return(2); } Directory.SetCurrentDirectory(new FileInfo((string)options.Parameters[0]).DirectoryName); EventListener collector = new EventCollector(options, outStream); string savedDirectory = Environment.CurrentDirectory; if (options.HasInclude) { Console.WriteLine("Included categories: " + options.include); testDomain.SetFilter(new CategoryFilter(options.IncludedCategories)); } else if (options.HasExclude) { Console.WriteLine("Excluded categories: " + options.exclude); testDomain.SetFilter(new CategoryFilter(options.ExcludedCategories, true)); } TestResult result = null; if (options.thread) { testDomain.RunTest(collector); testDomain.Wait(); result = testDomain.Result; } else { result = testDomain.Run(collector); } Directory.SetCurrentDirectory(savedDirectory); Console.WriteLine(); string xmlOutput = CreateXmlOutput(result); if (options.xmlConsole) { Console.WriteLine(xmlOutput); } else { CreateSummaryDocument(xmlOutput, transformReader); } // Write xml output here string xmlResultFile = options.IsXml ? options.xml : "TestResult.xml"; using (StreamWriter writer = new StreamWriter(xmlResultFile)) { writer.Write(xmlOutput); } if (testDomain != null) { testDomain.Unload(); } return(result.IsFailure ? 1 : 0); }
private void ThreadProc() { TestResult result = null; TestDomain testDomain = new TestDomain(); TestConsoleAccess consoleAccess = new TestConsoleAccess(); try { log.InfoFormat("Thread entered for Test {0}:{1} Assembly {2}", mPNUnitTestInfo.TestName, mPNUnitTestInfo.TestToRun, mPNUnitTestInfo.AssemblyName); ConsoleWriter outStream = new ConsoleWriter(Console.Out); ConsoleWriter errorStream = new ConsoleWriter(Console.Error); bool testLoaded = MakeTest(testDomain, Path.Combine(mConfig.PathToAssemblies, mPNUnitTestInfo.AssemblyName), GetShadowCopyCacheConfig()); if (!testLoaded) { log.InfoFormat("Unable to locate test {0}", mPNUnitTestInfo.TestName); result = BuildError("Unable to locate tests", consoleAccess); mPNUnitTestInfo.Services.NotifyResult( mPNUnitTestInfo.TestName, result); return; } Directory.SetCurrentDirectory(mConfig.PathToAssemblies); // test directory ? EventListener collector = new EventCollector(outStream); string savedDirectory = Environment.CurrentDirectory; log.Info("Creating PNUnitServices in the AppDomain of the test"); object[] param = { mPNUnitTestInfo, (ITestConsoleAccess)consoleAccess }; try { System.Runtime.Remoting.ObjectHandle obj #if NET_2_0 = Activator.CreateInstance( testDomain.AppDomain, #else = testDomain.AppDomain.CreateInstance( #endif typeof(PNUnitServices).Assembly.FullName, typeof(PNUnitServices).FullName, false, BindingFlags.Default, null, param, null, null, null); obj.Unwrap(); } catch (Exception e) { result = BuildError(e, consoleAccess); log.ErrorFormat("Error running test {0}", e.Message); return; } log.Info("Running tests"); try { ITestFilter filter = new NUnit.Core.Filters.SimpleNameFilter(mPNUnitTestInfo.TestToRun); result = FindResult( mPNUnitTestInfo.TestToRun, testDomain.Run(collector, filter)); filter = null; } catch (Exception e) { result = BuildError(e, consoleAccess); log.ErrorFormat("Error running test {0}", e.Message); } } finally { log.Info("Notifying the results"); mPNUnitTestInfo.Services.NotifyResult( mPNUnitTestInfo.TestName, BuildResult(result, consoleAccess)); result = null; //Bug with framework if (IsWindows()) { #if !NET_2_0 lock (obj) #endif { testDomain.Unload(); } } } }
private void ThreadProc() { PNUnitTestResult result = null; TestDomain testDomain = new TestDomain(); try { log.InfoFormat("Thread entered for Test {0}:{1} Assembly {2}", mTestInfo.TestName, mTestInfo.TestToRun, mTestInfo.AssemblyName); ConsoleWriter outStream = new ConsoleWriter(Console.Out); // ConsoleWriter errorStream = new ConsoleWriter(Console.Error); #if NUNIT_2_5 ITest test = MakeTest(testDomain, Path.Combine(mConfig.PathToAssemblies, mTestInfo.AssemblyName)); #else testDomain.ShadowCopyFiles = false; Test test = MakeTest(testDomain, Path.Combine(mConfig.PathToAssemblies, mTestInfo.AssemblyName)); #endif if (test == null) { Console.Error.WriteLine("Unable to locate tests"); mTestInfo.Services.NotifyResult( mTestInfo.TestName, null); return; } Directory.SetCurrentDirectory(mConfig.PathToAssemblies); // test directory ? EventListener collector = new EventCollector(outStream); // string savedDirectory = Environment.CurrentDirectory; log.Info("Creating PNUnitServices in the AppDomain of the test"); object[] param = { mTestInfo, (ITestConsoleAccess)this }; testDomain.AppDomain.CreateInstanceAndUnwrap( typeof(PNUnitServices).Assembly.FullName, typeof(PNUnitServices).FullName, false, BindingFlags.Default, null, param, null, null, null); log.Info("Running tests"); try { #if NUNIT_2_5 TestFilter filter = new NUnit.Core.Filters.SimpleNameFilter(mTestInfo.TestToRun); result = new PNUnitTestResult(testDomain.Run(collector, filter)); #else result = new PNUnitTestResult(testDomain.Run(collector, new string[1] { mTestInfo.TestToRun })[0]); #endif } catch (Exception e) { result = new PNUnitTestResult(e); } } finally { log.Info("Notifying the results"); mTestInfo.Services.NotifyResult( mTestInfo.TestName, result); //Bug with framework if (IsWindows()) { lock (obj) { log.Info("Unloading test appdomain"); testDomain.Unload(); log.Info("Unloaded test appdomain"); } } } }