Exemplo n.º 1
0
 internal TestSuiteLogger(TestSuiteLoggerParams testSuiteLoggerParams)
 {
     mTestSuiteLoggerParams = testSuiteLoggerParams;
 }
Exemplo n.º 2
0
        static void RunLauncher(string customLogFolder, string[] args)
        {
            TestGroup group = TestConfLoader.LoadFromFile(args[0], args);

            LauncherArgs launcherArgs = CliArgsReader.ProcessArgs(args, group);

            if ((group == null) || (group.ParallelTests.Count == 0))
            {
                Console.WriteLine("No tests to run");
                return;
            }

            TestSuiteLoggerParams loggerParams = CliArgsReader.ProcessTestSuiteLoggerArgs(args);

            NUnitResultCollector nunitReport = new NUnitResultCollector();
            LogWriter            logWriter   = new LogWriter(launcherArgs.ResultLogFile, launcherArgs.ErrorLogFile);

            try
            {
                string portValue = CliArgsReader.GetArgumentValue("--port=", args);
                int    port      = portValue == null ? DEFAULT_LAUNCHER_PORT : int.Parse(portValue);

                string ipToBind = CliArgsReader.GetArgumentValue("--iptobind=", args);

                Configurator.ConfigureRemoting(port, ipToBind ?? string.Empty);

                DateTime beginTimeStamp = DateTime.Now;

                TestSuiteLogger testSuiteLogger = null;

                if (loggerParams.IsInitialized())
                {
                    testSuiteLogger = new TestSuiteLogger(loggerParams);
                    testSuiteLogger.SaveBuild();
                    testSuiteLogger.CreateSuite();
                }

                Hashtable userValues = CliArgsReader.GetUserValues(args);

                Launcher launcher = new Launcher();

                string listenAddress = string.Format("{0}:{1}",
                                                     ipToBind ?? Environment.MachineName, port);

                List <string> testList = string.IsNullOrEmpty(launcherArgs.ListTestsFile) ?
                                         null :
                                         LoadTestsToRunFromFile(launcherArgs.ListTestsFile);

                Runner[] runners = launcher.RunTests(
                    group,
                    testList,
                    launcherArgs.MaxRetry,
                    launcherArgs.ShellMode,
                    launcherArgs.RetryOnFailure,
                    launcherArgs.FailedConfigFile,
                    testSuiteLogger,
                    launcherArgs.TestsTimeout,
                    launcherArgs.TestRange,
                    userValues,
                    logWriter,
                    listenAddress,
                    launcherArgs.UseFileReport);

                DateTime endTimeStamp = DateTime.Now;

                FillNunitReport(nunitReport, runners);

                if (CliArgsReader.GetArgumentValue("--skipsummarylog", args) != null)
                {
                    return;
                }

                LogWriter.PrintResults(
                    runners,
                    beginTimeStamp, endTimeStamp, logWriter);
            }
            finally
            {
                logWriter.WriteFullLog(launcherArgs.ResultFile);
                nunitReport.SaveResults(Path.Combine(customLogFolder, "pnunit-results.xml"));
            }
        }