Example #1
0
        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);
        }
Example #2
0
        TestResult RunTest(
            PNUnitTestInfo testInfo,
            ConsoleWriter outStream,
            TestRunner testRunner)
        {
            EventListener collector = new EventCollector(outStream);

            ITestFilter filter = new NUnit.Core.Filters.SimpleNameFilter(
                testInfo.TestToRun);

            TestResult result = testRunner.Run(
                collector, filter, true, LoggingThreshold.All);

            result = FindResult(testInfo.TestToRun, result);

            return(result);
        }
Example #3
0
		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");
					}
				}
			}

		}
Example #4
0
        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");
                    }
                }
            }
        }
        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()
        {
            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();
                    }
                }
            }
        }
Example #7
0
        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;
        }