Exemple #1
0
 public OutputHelper(ITestOutputHelper output, FileTestOutputHelper fileLogger, ConsoleTestOutputHelper consoleLogger)
 {
     _output        = output;
     _fileLogger    = fileLogger;
     _consoleLogger = consoleLogger;
     IndentedOutput = new IndentedTestOutputHelper(this);
 }
Exemple #2
0
        private async Task UncachedExecute(TestStepState stepState, ITestOutputHelper output)
        {
            using (FileTestOutputHelper stepLog = new FileTestOutputHelper(_logFilePath))
            {
                try
                {
                    LogHeader(stepState, false, output);
                    MultiplexTestOutputHelper mux = new MultiplexTestOutputHelper(new IndentedTestOutputHelper(output), stepLog);
                    await DoWork(mux);

                    stepState = stepState.Complete();
                }
                catch (Exception e)
                {
                    stepState = stepState.Fault(e.Message, e.StackTrace);
                }
                finally
                {
                    LogFooter(stepState, output);
                    await WriteFinalStepState(stepState, output);

                    ThrowExceptionIfFaulted(stepState);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Returns an output helper for the specified config.
        /// </summary>
        /// <param name="config">test config</param>
        /// <param name="output">starting output helper</param>
        /// <param name="testName">test case name</param>
        /// <returns>new output helper</returns>
        public static TestRunner.OutputHelper ConfigureLogging(TestConfiguration config, ITestOutputHelper output, string testName)
        {
            FileTestOutputHelper    fileLogger    = null;
            ConsoleTestOutputHelper consoleLogger = null;

            if (!string.IsNullOrEmpty(config.LogDirPath))
            {
                string logFileName = testName + "." + config.ToString() + ".log";
                string logPath     = Path.Combine(config.LogDirPath, logFileName);
                fileLogger = new FileTestOutputHelper(logPath, FileMode.Append);
            }
            if (config.LogToConsole)
            {
                consoleLogger = new ConsoleTestOutputHelper();
            }
            return(new TestRunner.OutputHelper(output, fileLogger, consoleLogger));
        }