コード例 #1
0
        NUnitTestRunner GetRunner(string assemblyPath, bool forQuery)
        {
            string basePath = Path.GetDirectoryName(GetType().Assembly.Location);

            TestPackage package = new TestPackage(assemblyPath);

            package.Settings ["ShadowCopyFiles"] = false;

            // This is a workaround for what could be a Mono bug (hard to tell).
            // For the test runner to be able to load the app.config file,
            // the BasePath of the domain needs to be set to the location
            // of the test assembly (see bug #41541 - App Config is not read in Unit Tests).
            // However, when doing that, the test runner crashes in some cases
            // (for example when loading the MD unit tests). It crashes because
            // Mono gets confused and tries to load assemblies from two different
            // locations. As a workaround, we set the test assebmly directory
            // as base path only when running, which seems to work.

            if (forQuery)
            {
                package.BasePath = basePath;
            }
            else
            {
                package.BasePath = Path.GetDirectoryName(assemblyPath);
            }

            AppDomain domain = Services.DomainManager.CreateDomain(package);
            string    asm    = Path.Combine(basePath, "NUnitRunner.exe");

            runner = (NUnitTestRunner)domain.CreateInstanceFromAndUnwrap(asm, "MonoDevelop.UnitTesting.NUnit.External.NUnitTestRunner");
            runner.Initialize();
            return(runner);
        }
コード例 #2
0
        NUnitTestRunner GetRunner(string assemblyPath)
        {
            string basePath = Path.GetDirectoryName(GetType().Assembly.Location);

            TestPackage package = new TestPackage(assemblyPath);

            package.Settings ["ShadowCopyFiles"] = false;
            package.BasePath = Path.GetDirectoryName(assemblyPath);

            AppDomain domain = Services.DomainManager.CreateDomain(package);
            string    asm    = Path.Combine(basePath, "NUnitRunner.exe");

            runner = (NUnitTestRunner)domain.CreateInstanceFromAndUnwrap(asm, "MonoDevelop.UnitTesting.NUnit.External.NUnitTestRunner");
            runner.Initialize();
            return(runner);
        }
コード例 #3
0
		NUnitTestRunner GetRunner (string assemblyPath)
		{
			string basePath = Path.GetDirectoryName (GetType ().Assembly.Location);

			TestPackage package = new TestPackage (assemblyPath);
			package.Settings ["ShadowCopyFiles"] = false;
			package.BasePath = Path.GetDirectoryName(assemblyPath);
			
			AppDomain domain = Services.DomainManager.CreateDomain (package);
			string asm = Path.Combine (basePath, "NUnitRunner.exe");
			runner = (NUnitTestRunner)domain.CreateInstanceFromAndUnwrap (asm, "MonoDevelop.UnitTesting.NUnit.External.NUnitTestRunner");
			runner.Initialize ();
			return runner;
		}