Exemplo n.º 1
0
 public void UnregisterConsole(ITestConsoleAccess console)
 {
     lock (mConsoles)
     {
         mConsoles.Remove(console);
     }
 }
Exemplo n.º 2
0
 public void RegisterConsole(ITestConsoleAccess console)
 {
     lock (mConsoles)
     {
         if (!mConsoles.Contains(console))
         {
             mConsoles.Add(console);
         }
     }
 }
Exemplo n.º 3
0
 public GuiTestRunner(
     string testInfoFile,
     string pathToAssemblies,
     IGuiFinalizer guiFinalizer,
     ITestConsoleAccess guiConsole)
 {
     mTestInfoFile     = testInfoFile;
     mPathToAssemblies = pathToAssemblies;
     mGuiFinalizer     = guiFinalizer;
     mGuiConsole       = guiConsole;
 }
Exemplo n.º 4
0
 // To be used only by the runner
 public PNUnitServices(
     PNUnitTestInfo info,
     IPNUnitServices services,
     ITestConsoleAccess consoleAccess,
     ITestLogInfo testLogInfo)
 {
     mInfo     = info;
     mServices = services;
     mConsoles = new ArrayList();
     mConsoles.Add(consoleAccess);
     mTestLogInfo = testLogInfo;
     mInstance    = this;
 }
Exemplo n.º 5
0
        static void CreatePNUnitServices(
            PNUnitTestInfo testInfo,
            TestRunner testRunner,
            IPNUnitServices services,
            TestConsoleAccess consoleAccess,
            TestLogInfo testLogInfo,
            ITestConsoleAccess extraConsoleAccess)
        {
            // Intialize the singleton
            new PNUnitServices(testInfo, services, consoleAccess, testLogInfo);

            if (extraConsoleAccess != null)
            {
                PNUnitServices.Get().RegisterConsole(extraConsoleAccess);
            }
        }
 // To be used only by the runner
 public PNUnitServices(object info, object consoleaccess)
 {
     mInfo = info as PNUnitTestInfo;
     mConsole = consoleaccess as ITestConsoleAccess;
     mInstance = this;
 }
Exemplo n.º 7
0
 // To be used only by the runner
 public PNUnitServices(object info, object consoleaccess)
 {
     mInfo     = info as TestInfo;
     mConsole  = consoleaccess as ITestConsoleAccess;
     mInstance = this;
 }
Exemplo n.º 8
0
 public void UnregisterConsole(ITestConsoleAccess console)
 {
     lock (mConsoles)
     {
         mConsoles.Remove(console);
     }
 }
Exemplo n.º 9
0
 public void RegisterConsole(ITestConsoleAccess console)
 {
     lock (mConsoles)
     {
         if (!mConsoles.Contains(console))
             mConsoles.Add(console);
     }
 }
Exemplo n.º 10
0
        public void Run(
            PNUnitTestInfo testInfo,
            IPNUnitServices services,
            ITestConsoleAccess extraConsoleAccess)
        {
            try
            {
                TestResult result = null;

                TestRunner testRunner = null;

                TestConsoleAccess consoleAccess = new TestConsoleAccess(testInfo.OutputFile);

                TestLogInfo testLogInfo = new TestLogInfo();

                try
                {
                    mLog.DebugFormat("Running test {0}:{1} Assembly {2}",
                                     testInfo.TestName,
                                     testInfo.TestToRun,
                                     testInfo.AssemblyName);

                    ConsoleWriter outStream   = new ConsoleWriter(Console.Out);
                    ConsoleWriter errorStream = new ConsoleWriter(Console.Error);

                    testRunner = SetupTest(testInfo, services, consoleAccess,
                                           testLogInfo, extraConsoleAccess);

                    if (testRunner == null)
                    {
                        return;
                    }

                    mLog.DebugFormat("RunTest {0}", testInfo.TestName);

                    PrintSeparator();

                    try
                    {
                        result = RunTest(testInfo, outStream, testRunner);
                    }
                    catch (Exception e)
                    {
                        mLog.ErrorFormat("Error running test {0}. {1}", testInfo.TestName, e.Message);
                        mLog.Debug(e.StackTrace);

                        result = BuildError(testInfo, e, consoleAccess, testLogInfo);
                    }
                }
                catch (Exception e)
                {
                    mLog.ErrorFormat("Error launching tests: {0}", e.Message);
                    mLog.Debug(e.StackTrace);

                    result = BuildError(testInfo,
                                        e, consoleAccess, testLogInfo);
                }
                finally
                {
                    mLog.InfoFormat("Notifying the results {0}",
                                    testInfo.TestName);

                    PNUnitTestResult pnunitResult = BuildResult(
                        testInfo,
                        result, consoleAccess, testLogInfo);

                    mLog.DebugFormat("Result built!! Now, notify the launcher ... {0}",
                                     testInfo.TestName);

                    try
                    {
                        services.NotifyResult(
                            testInfo.TestName, pnunitResult);
                        mLog.DebugFormat("<-Results NOTIFIED - {0}",
                                         testInfo.TestName);
                    }
                    catch (Exception e)
                    {
                        mLog.ErrorFormat(
                            "Error notifying back the result of test {0}. {1}",
                            testInfo.TestName, e.Message);
                        mLog.Error(
                            "If you're using a custom launcher.remoting.conf" +
                            " check that you've defined the binaryFormatter");
                    }

                    result = null;

                    UnloadTests(testRunner);
                }
            }
            catch (Exception ex)
            {
                mLog.ErrorFormat("Error running test {0} {1}",
                                 testInfo.TestName, ex.Message);
                mLog.Debug(ex.StackTrace);
            }
        }
Exemplo n.º 11
0
        TestRunner SetupTest(
            PNUnitTestInfo testInfo,
            IPNUnitServices services,
            TestConsoleAccess consoleAccess,
            TestLogInfo testLogInfo,
            ITestConsoleAccess extraConsoleAccess)
        {
            TestRunner result;
            bool       testAssemblyLoaded;

            if (mPreloader == null)
            {
                result = new SimpleTestRunner();

                int ini = Environment.TickCount;

                string fullAssemblyPath = Path.GetFullPath(
                    Path.Combine(mPathToAssemblies, testInfo.AssemblyName));

                mLog.DebugFormat("Loading test assembly from {0}", fullAssemblyPath);

                testAssemblyLoaded = MakeTest(result, fullAssemblyPath);

                mLog.DebugFormat("Load test assembly {0} ms", Environment.TickCount - ini);
            }
            else
            {
                //if (!AssemblyPreload.CanUsePreload(testInfo.AssemblyName))
                //{
                //    throw new Exception(
                //        "The preloaded and the target assembly don't match!!");
                //}

                result             = mPreloader.TestRunner;
                testAssemblyLoaded = mPreloader.TestAssemblyLoaded;
            }

            if (!testAssemblyLoaded)
            {
                mLog.InfoFormat("Unable to load test assembly {0} for test {1}",
                                testInfo.AssemblyName,
                                testInfo.TestName);

                PNUnitTestResult testResult = BuildError(
                    testInfo, new Exception("Unable to locate tests"),
                    consoleAccess, testLogInfo);

                services.NotifyResult(
                    testInfo.TestName, testResult);

                return(null);
            }

            mLog.Debug("Test loaded, going to set CurrentDirectory");

            Directory.SetCurrentDirectory(mPathToAssemblies);

            mLog.Debug("Creating PNUnit services");

            CreatePNUnitServices(testInfo, result, services, consoleAccess,
                                 testLogInfo, extraConsoleAccess);

            return(result);
        }