Example #1
1
 private static TestResult RunTests( string assemFile, ConsoleListener l )
 {
     TestPackage testPackage = new TestPackage( assemFile );
     RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
     remoteTestRunner.Load( testPackage );
     return remoteTestRunner.Run( l, TestFilter.Empty, false, LoggingThreshold.Debug );
 }
Example #2
0
 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;
 }
Example #3
0
 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;
 }
Example #4
0
        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);
        }
Example #5
0
 public Result Run(string file, Result compileResult)
 {
     RemoteTestRunner runner = new RemoteTestRunner();
     TestPackage package = new TestPackage("Test");
     package.Assemblies.Add(file);
     if (runner.Load(package))
     {
         TestResult result = runner.Run(new TestListner(compileResult), new TestFilter(), false, LoggingThreshold.All);
     }
     return compileResult;
 }
Example #6
0
		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);
		}
Example #7
0
        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 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 ");
        }
        static void Main(string[] args)
        {
            try {

            CoreExtensions.Host.InitializeService();

            int port = int.Parse(args[1]);

            TSocket socket = new TSocket("localhost", port);

            TestInterface.Client client = new TestInterface.Client(new TBinaryProtocol(socket));

            socket.Open();

            TestPackage testPackage = new TestPackage(args[0]);
            RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
            remoteTestRunner.Load(testPackage);
            remoteTestRunner.Run(new OurEventListener(client), TestFilter.Empty, false, LoggingThreshold.All);
              }
              catch(Exception e) {
            System.Console.WriteLine(e.Message + "\n" + e.StackTrace);
              }
        }
Example #10
0
        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 SledSharedEventListener {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;
        }
Example #11
0
        /// <summary>
        /// This is a "manual" test runner for the NUnit tests.  I made this so I can easily
        /// debug the individual tests without having to attach the debugger to the NUnit GUI process, etc.
        /// </summary>
        /// <param name="args"></param>
        static void Main(String[] args)
        {
            Debug.WriteLine("TestRunner starting...");

            var path = Assembly.GetExecutingAssembly().Location;

            CoreExtensions.Host.InitializeService();
            using (var testRunner = new RemoteTestRunner())
            {
                var package = new TestPackage("NCraft.Test.exe", new List<string>() { path });
                testRunner.Load(package);

                testRunner.Run(new LoggingEventListener(), TestFilter.Empty);
            }

            Debug.WriteLine("TestRunner complete!");
        }