public static int RunAllTests() { var executingAssembly = Assembly.GetExecutingAssembly(); var assemblyFilename = executingAssembly.Location; var consoleOut = Console.Out; var testPackage = new TestPackage(assemblyFilename) { AutoBinPath = true }; testPackage.Settings["ShadowCopyFiles"] = false; testPackage.Settings["UseThreadedRunner"] = false; var listener = new SledEventListener { ConsoleOut = consoleOut }; var testRunner = new RemoteTestRunner(); testRunner.Load(testPackage); testRunner.Run(listener); if (listener.FailedTestCount == 0) { consoleOut.WriteLine("Success: " + listener.TestCount + " test(s) passed."); } return(listener.FailedTestCount); }
public SessionResults RunAssembly(Assembly assembly, IEnumerable <string> filters) { this.filters = filters; var remoteTestRunner = new RemoteTestRunner(0); var package = SetupTestPackager(assembly); remoteTestRunner.Load(package); var listener = new GilesNUnitEventListener(); if (filters.Count() == 0) { remoteTestRunner.Run(listener); } else { remoteTestRunner.Run(listener, GetFilters()); } return(listener.SessionResults); }
public SessionResults RunAssembly(Assembly assembly) { var remoteTestRunner = new RemoteTestRunner(0); var package = SetupTestPackager(assembly); remoteTestRunner.Load(package); var listener = new GilesNUnitEventListener(); remoteTestRunner.Run(listener); return(listener.SessionResults); }
static void Main(string[] args) { CoreExtensions.Host.InitializeService(); TestSuiteBuilder builder = new TestSuiteBuilder(); TestPackage testPackage = new TestPackage(@"d:\Programming\RoboFootball\Platform\Arbiter.Test\bin\Debug\Arbiter.Test.dll"); RemoteTestRunner remoteTestRunner = new RemoteTestRunner(); remoteTestRunner.Load(testPackage); remoteTestRunner.Run(new NullListener(), new SingleTestFilter("StartWithOneTeam"), false, LoggingThreshold.Error); }
public void RunMultipleAssemblies() { assemblies[0] = "nonamespace-assembly.dll"; Test test = runner.Load("TestSuite", assemblies); TestResult result = runner.Run(NullListener.NULL); ResultSummarizer summary = new ResultSummarizer(result); Assert.AreEqual( NoNamespaceTestFixture.Tests + MockAssembly.Tests - MockAssembly.NotRun, summary.ResultCount); }
private void DoTests() { var currentOut = Console.Out; TestFilter filter = (_testsToRun != null ? new SimpleNameFilter(_testsToRun) : TestFilter.Empty); Result = _remoteTestRunner.Run(new NullListener(), filter, false, LoggingThreshold.Off); ExitCode = Result.IsSuccess ? 0 : 1; Console.SetOut(currentOut); //WriteErrorsAndFailuresReport(Result); }
private TestResult runTest() { CoreExtensions.Host.InitializeService(); TestPackage testPackage = new TestPackage(this.path); RemoteTestRunner rtr = new RemoteTestRunner(); rtr.Load(testPackage); TestResult tr = rtr.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Error); XmlResultWriter xmlw = new XmlResultWriter(Directory.GetCurrentDirectory() + @"\TempResults\testResult.xml"); xmlw.SaveTestResult(tr); return(tr); }
public void Run() { if (!File.Exists(_path)) { return; } var testPackage = new TestPackage(_path); var remoteTestRunner = new RemoteTestRunner(); if (!remoteTestRunner.Load(testPackage)) { return; } var testResult = remoteTestRunner.Run(_eventListener, TestFilter.Empty, false, LoggingThreshold.Error); }
public TestResult Run(EventListener listener, ITestFilter filter, string path, string suiteName, List <string> supportAssemblies) { InitSupportAssemblies(supportAssemblies); if (filter == null) { filter = TestFilter.Empty; } RemoteTestRunner tr = new RemoteTestRunner(); TestPackage package = new TestPackage(path); if (!string.IsNullOrEmpty(suiteName)) { package.TestName = suiteName; } tr.Load(package); return(tr.Run(listener, filter, false, LoggingThreshold.All)); }
public override void ExecuteTest(object instance, string testId, string methodName) { using (RemoteTestRunner testRunner = new RemoteTestRunner()) { TestPackage package = new TestPackage("FieldTest"); package.Assemblies.Add(instance.GetType().Assembly.Location); testRunner.Load(package); var testCount = testRunner.CountTestCases(new NameFilter()); var testToRun = GetMatchingTest(methodName, testRunner.Test); var testFilter = new NameFilter(testToRun.TestName); TestResult result = testRunner.Run(new NullListener(), testFilter); if (result.IsSuccess) { _testResultReporter.ReportTestResult(testId, "Passed", string.Empty); } else { result = GetMatchingTestResult(methodName, result); if (result != null) { if (result.ResultState == ResultState.Inconclusive) { _testResultReporter.ReportTestResult(testId, "Inconclusive", string.Format("{0} {1}", result.Message, result.StackTrace)); } else { _testResultReporter.ReportTestResult(testId, "Failed", string.Format("{0} {1}", result.Message, result.StackTrace)); } } else { _testResultReporter.ReportTestResult(testId, "Failed", string.Empty); } } testRunner.Unload(); } }
private TestResult RunTestsInAssemblies(IList assemblies, ITestFilter testfilter) { // Note: in order for nunit to unload assembly (not lock it) // we are using a modified version of nunit.core.dll (and the dependent nunit.interfaces.dll) // if the nunit dlls are updated this is what needs to be changed: // in TestAssemblyBuilder class in Load method, // change "assembly = Assembly.Load(assemblyName);" // to "assembly = Assembly.Load(File.ReadAllBytes(path));" TestPackage theTestPackage = new TestPackage("All Dlls", assemblies); theTestPackage.Settings.Add("UseThreadedRunner", false); theTestPackage.Settings.Add("DomainUsage", DomainUsage.None); RemoteTestRunner testRunner = new RemoteTestRunner(); testRunner.Load(theTestPackage); TestResult testResult = testRunner.Run(NullListener.NULL, testfilter, false, LoggingThreshold.Off); // Dispose testRunner.Unload(); testRunner.Dispose(); return(testResult); }
public static WebSharper.UI.Doc MainDoc(View <CalculatorViewModel> viewCalculator, Var <CalculatorViewModel> varCalculator) { // Page visibility without state machine var page = Var.Create(Single); // Setup the reactive ViewState storage and the test button. var viewState = Var.Create(""); var testSummary = new ListModel <string, string>(s => s); return(WebSharper.UI.Doc.ConcatMixed( input(viewState, attr.type("hidden")) , new Template.Index.Main() // Test button with result summary .Test(async(el, ev) => { var result = await RemoteTestRunner.Run("asptest.websharper.spa"); testSummary.Clear(); testSummary.AppendMany(result.Summary); if (!result.Passed) { JS.Window.Location.Assign(TestResultSite.ResultXmlPath); } }) .TestSummaryContainer( testSummary.View.DocSeqCached((string x) => new Template.Index.TestSummaryItem().Line(x).Doc() ) ) .ResultXmlPath(TestResultSite.ResultXmlPath) .Doc() , Page(page, viewCalculator, varCalculator) )); }
/// <summary> /// Main page as template. /// </summary> /// <returns></returns> public static WebSharper.UI.Doc IndexDoc() { var testSummary = new ListModel <string, string>(s => s); return(new Template.Index.Main() // Links to sub-pages .WithStatic((el, ev) => { WithStaticDoc().RunById("page"); }) .WithStorage((el, ev) => { WithStorageDoc().RunById("page"); }) // Test button with result summary .Test(async(el, ev) => { var result = await RemoteTestRunner.Run("minimaltest.websharper.spa"); testSummary.Clear(); testSummary.AppendMany(result.Summary); if (!result.Passed) { JS.Window.Location.Assign(TestResultSite.ResultXmlPath); } }) .TestSummaryContainer( testSummary.View.DocSeqCached((string x) => new Template.Index.TestSummaryItem().Line(x).Doc() ) ) .ResultXmlPath(TestResultSite.ResultXmlPath) .Doc()); }
/// <summary> /// Runs all unit tests on this assembly. /// </summary> /// <returns>Number of failed tests.</returns> public Results Run() { runner.Run(this); return(domain.GetData("Results") as Results); }
public void RunTest(string setUp, string testName, string tearDown) { var testResult = remoteTesRunner.Run(new NullListener(), new SingleTestFilter(setUp), false, LoggingThreshold.Info); var testResult1 = remoteTesRunner.Run(new NullListener(), new SingleTestFilter(testName), false, LoggingThreshold.Info); var testResult2 = remoteTesRunner.Run(new NullListener(), new SingleTestFilter(tearDown), false, LoggingThreshold.Info); }
public void generateAndRunVBObjectTests() { int i = 0; DirectoryInfo d = new DirectoryInfo(Directory.GetCurrentDirectory()); while (true) { i++; if (i >= 20) { throw new ApplicationException("could not get a dir with name GeneratorTests"); } d = d.Parent; if (d.Name == "GeneratorTests") { break; } } string path = d.FullName + "\\VbObjectTestsTmp.cs"; if (File.Exists(path)) { File.Delete(path); } File.Copy(d.FullName + "\\CSharpObjectTests.cs", path); string readText = File.ReadAllText(path); readText = readText.Replace("using CsModelObjects;", "using ModelLibVBGenCode.VbBusObjects;"); readText = readText.Replace("using CsModelMappers;", "using ModelLibVBGenCode.VbBusObjects.DBMappers;"); //readText = readText.Replace("DateTime hireDate=new", "dim hireDate as DateTime=new"); readText = readText.Replace("namespace GeneratorTests {", "namespace GeneratorTests.VB {"); readText = readText.Replace("public class CSharpObjectTests {", "public class VBObjectTests {"); readText = readText.Replace("public void createCsRecords()", "public void createVbRecords()"); readText = readText.Replace("[TestClass]", "[NUnit.Framework.TestFixture]"); readText = readText.Replace("[TestMethod]", "[NUnit.Framework.Test]"); readText = readText.Replace("using Microsoft.VisualStudio.TestTools.UnitTesting;", "using NUnit.Framework;"); readText = readText.Replace("Assert.", "NUnit.Framework.Assert."); readText = readText.Replace("public static void MyClassInitialize(TestContext testContext)", "public static void MyClassInitialize()"); readText = readText.Replace("[ClassInitialize()]", "[NUnit.Framework.SetUp]"); readText = readText.Replace("[ClassCleanup()]", "[NUnit.Framework.TearDown]"); readText = readText.Replace("//NUnit.Framework.NUnit.Framework.Assert.IsTrue(false)", "NUnit.Framework.Assert.IsTrue(false);"); readText = readText.Replace("//DBUtils.Current().ConnString=", "org.model.lib.db.DBUtils.Current().ConnString=\"" + DBUtils.Current().ConnString.Replace("\\", "\\\\") + "\";"); readText = readText.Replace("EnumProjectType.EXTERNAL", "ModelLibVBGenCode.EnumProjectType.EXTERNAL"); readText = readText.Replace("void testCSharp", "void testVBNet"); File.WriteAllText(path, readText); CSharpCodeProvider provider = new CSharpCodeProvider(); CompilerParameters cp = new CompilerParameters(); // this line is here otherwise ModelLibVBGenCode is not returned // in call to this.GetType().Assembly.GetReferencedAssemblies ModelLibVBGenCode.VbBusObjects.Employee e = null; NUnit.Framework.Guard x = null; // note: DO NOT REMOVE! var assemblies = this.GetType().Assembly.GetReferencedAssemblies().ToList(); var assemblyLocations = assemblies.Select(a => Assembly.ReflectionOnlyLoad(a.FullName).Location); var lstAssemblyLocations = assemblyLocations.Where(a => !a.Contains("Microsoft.VisualStudio.QualityTools.UnitTestFramework")).ToList(); //Assembly.ReflectionOnlyLoad("") cp.ReferencedAssemblies.AddRange(lstAssemblyLocations.ToArray()); cp.GenerateInMemory = false; // True - memory generation, false - external file generation cp.GenerateExecutable = false; // True - exe file generation, false - dll file generation CompilerResults results = provider.CompileAssemblyFromSource(cp, readText); Assert.AreEqual(0, results.Errors.Count, "There should be no compilation errors, first error was:" + (results.Errors.Count > 0 ? results.Errors[0].ErrorText : "")); CoreExtensions.Host.InitializeService(); TestPackage package = new TestPackage(results.CompiledAssembly.Location); RemoteTestRunner remoteTestRunner = new RemoteTestRunner(); remoteTestRunner.Load(package); TestResult result = remoteTestRunner.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.All); Assert.IsTrue(result.HasResults, " must have test results "); Assert.IsTrue(result.IsSuccess, "dynamic vb tests must return success "); }