Пример #1
0
        internal static void NotifyError(Exception e, PNUnitTestInfo info)
        {
            TestLogInfo testLogInfo = new TestLogInfo();

            testLogInfo.SetOSVersion(Environment.OSVersion.Platform.ToString());

            TestName testName = new TestName();

            testName.Name     = info.TestName;
            testName.FullName = info.TestName;
            testName.TestID   = new TestID();

            PNUnitTestResult result = new PNUnitTestResult(
                testName, info.GetTestOutput(),
                testLogInfo.OSVersion, testLogInfo.BackendType, true);

            string fullMessage = string.Format(
                "TestName: {0}; Error: {1}; EXCEPTION TYPE: {2}; STACK TRACE: {3}",
                testName.Name, e.Message, e.GetType(), e.StackTrace);

            result.Failure(fullMessage, string.Empty);

            info.DeleteTestOutput();

            IPNUnitServices services =
                PNUnitServices.GetPNunitServicesProxy(info.PNUnitServicesServer);

            services.NotifyResult(info.TestName, result);
        }
Пример #2
0
        static void RunPreload(string pathToAssemblies)
        {
            mLog.Debug("Preload started. Path To assemblies:" + pathToAssemblies);
            InitServices.InitNUnitServices();

            PNUnitTestRunner runner = new PNUnitTestRunner(pathToAssemblies);

            runner.Preload();

            int pidOfThisExpectedByAgent = Codice.Test.PlatformIdentifier.IsWindows() ?
                                           System.Diagnostics.Process.GetCurrentProcess().Id :
                                           Mono.Unix.UnixEnvironment.GetParentProcessId();

            string testInfoFile = Path.Combine(
                Path.GetTempPath(),
                PNUnit.Agent.AssemblyPreload.PRELOADED_PROCESS_FILE_PREFIX + pidOfThisExpectedByAgent.ToString());

            int count = 0;

            while (!File.Exists(testInfoFile))
            {
                System.Threading.Thread.Sleep(150);
                mLog.DebugFormat("Waiting for testinfo file to be created...: {0}", testInfoFile);

                count++;

                if (count >= 6000) //wait 1,5 minutes for test arrival
                {
                    mLog.Fatal("Tired of waiting: Cannot execute tests without information; exiting ...");
                    Environment.Exit(1);
                }
            }

            mLog.DebugFormat("Preload read {0} from file", testInfoFile);

            PNUnitTestInfo info = TestInfoReader.ReadTestInfo(testInfoFile);

            if (info == null)
            {
                mLog.Fatal("Cannot execute tests without information; exiting ...");
                Environment.Exit(1);
            }

            ProcessNameSetter.SetProcessName(info.TestName);

            IPNUnitServices services =
                PNUnitServices.GetPNunitServicesProxy(info.PNUnitServicesServer);

            runner.Run(info, services, null);
        }
Пример #3
0
        static void RunOnce(string testInfoFile, string pathToAssemblies)
        {
            PNUnitTestInfo info = TestInfoReader.ReadTestInfo(testInfoFile);

            if (info == null)
            {
                Console.WriteLine("Cannot execute tests without information; exiting ...");
                Environment.Exit(1);
            }

            ProcessNameSetter.SetProcessName(info.TestName);

            IPNUnitServices services =
                PNUnitServices.GetPNunitServicesProxy(info.PNUnitServicesServer);

            if (info.TestName.StartsWith("run-nunit"))
            {
                new NUnitTestRunner(info, pathToAssemblies).Run(services);
                return;
            }

            new PNUnitTestRunner(pathToAssemblies).Run(info, services, null);
        }
Пример #4
0
 static IPNUnitServices GetPNUnitServices(string server)
 {
     return(string.IsNullOrEmpty(server)
         ? new DummyPnunitServices()
         : PNUnitServices.GetPNunitServicesProxy(server));
 }