void HandleTestAssemblyFinished(MessageHandlerArgs<ITestAssemblyFinished> args)
        {
            ExecutionSummary.Total = args.Message.TestsRun;
            ExecutionSummary.Failed = args.Message.TestsFailed;
            ExecutionSummary.Skipped = args.Message.TestsSkipped;
            ExecutionSummary.Time = args.Message.ExecutionTime;
            ExecutionSummary.Errors = errors;

            completionCallback?.Invoke(Path.GetFileNameWithoutExtension(args.Message.TestAssembly.Assembly.AssemblyPath), ExecutionSummary);

            Finished.Set();
        }
 /// <summary>
 /// Called when <see cref="ITestSkipped"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestSkipped(MessageHandlerArgs<ITestSkipped> args)
 {
     lock (Logger.LockObject)
     {
         var testSkipped = args.Message;
         Logger.LogWarning($"    {Escape(testSkipped.Test.DisplayName)} [SKIP]");
         Logger.LogImportantMessage($"      {Escape(testSkipped.Reason)}");
     }
 }
 void HandleTestAssemblyCleanupFailure(MessageHandlerArgs<ITestAssemblyCleanupFailure> args)
     => AddError("assembly-cleanup", args.Message.TestAssembly.Assembly.AssemblyPath, args.Message);
Пример #4
0
 void HandleTestCollectionCleanupFailure(MessageHandlerArgs <ITestCollectionCleanupFailure> args)
 => AddError("test-collection-cleanup", args.Message.TestCollection.DisplayName, args.Message);
Пример #5
0
 void HandleErrorMessage(MessageHandlerArgs <IErrorMessage> args)
 => AddError("fatal", null, args.Message);
 /// <summary>
 /// Called when <see cref="ITestAssemblyCleanupFailure"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestAssemblyCleanupFailure(MessageHandlerArgs <ITestAssemblyCleanupFailure> args)
 => LogError($"Test Assembly Cleanup Failure ({args.Message.TestAssembly.Assembly.AssemblyPath})", args.Message);
Пример #7
0
 void HandleTestCaseStarting(MessageHandlerArgs <ITestCaseStarting> args)
 => executingTestCases.TryAdd(args.Message.TestCase, UtcNow);
 void HandleTestAssemblyFinished(MessageHandlerArgs<ITestAssemblyFinished> args)
 {
     stopEvent.Set();
 }
 void HandleTestCollectionFinished(MessageHandlerArgs<ITestCollectionFinished> args)
 {
     var testCollectionFinished = args.Message;
     var collectionElement = GetTestCollectionElement(testCollectionFinished.TestCollection);
     collectionElement.Add(
         new XAttribute("total", testCollectionFinished.TestsRun),
         new XAttribute("passed", testCollectionFinished.TestsRun - testCollectionFinished.TestsFailed - testCollectionFinished.TestsSkipped),
         new XAttribute("failed", testCollectionFinished.TestsFailed),
         new XAttribute("skipped", testCollectionFinished.TestsSkipped),
         new XAttribute("name", XmlEscape(testCollectionFinished.TestCollection.DisplayName)),
         new XAttribute("time", testCollectionFinished.ExecutionTime.ToString("0.000", CultureInfo.InvariantCulture))
     );
 }
 void HandleTestCollectionCleanupFailure(MessageHandlerArgs<ITestCollectionCleanupFailure> args)
     => AddError("test-collection-cleanup", args.Message.TestCollection.DisplayName, args.Message);
 void HandleTestClassCleanupFailure(MessageHandlerArgs<ITestClassCleanupFailure> args)
     => AddError("test-class-cleanup", args.Message.TestClass.Class.Name, args.Message);
 void HandleTestCaseCleanupFailure(MessageHandlerArgs<ITestCaseCleanupFailure> args)
     => AddError("test-case-cleanup", args.Message.TestCase.DisplayName, args.Message);
        void HandleTestAssemblyStarting(MessageHandlerArgs<ITestAssemblyStarting> args)
        {
            var assemblyStarting = args.Message;
            assemblyElement.Add(
                new XAttribute("name", assemblyStarting.TestAssembly.Assembly.AssemblyPath),
                new XAttribute("environment", assemblyStarting.TestEnvironment),
                new XAttribute("test-framework", assemblyStarting.TestFrameworkDisplayName),
                new XAttribute("run-date", assemblyStarting.StartTime.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)),
                new XAttribute("run-time", assemblyStarting.StartTime.ToString("HH:mm:ss", CultureInfo.InvariantCulture))
            );

            if (assemblyStarting.TestAssembly.ConfigFileName != null)
                assemblyElement.Add(new XAttribute("config-file", assemblyStarting.TestAssembly.ConfigFileName));
        }
        void HandleTestAssemblyFinished(MessageHandlerArgs<ITestAssemblyFinished> args)
        {
            assemblyElement.Add(
                new XAttribute("total", ExecutionSummary.Total),
                new XAttribute("passed", ExecutionSummary.Total - ExecutionSummary.Failed - ExecutionSummary.Skipped),
                new XAttribute("failed", ExecutionSummary.Failed),
                new XAttribute("skipped", ExecutionSummary.Skipped),
                new XAttribute("time", ExecutionSummary.Time.ToString("0.000", CultureInfo.InvariantCulture)),
                new XAttribute("errors", ExecutionSummary.Errors)
            );

            foreach (var element in testCollectionElements.Values)
                assemblyElement.Add(element);
        }
 void HandleTestAssemblyFinished(MessageHandlerArgs <ITestAssemblyFinished> args)
 {
     stopEvent.Set();
 }
 void HandleTestCaseFinished(MessageHandlerArgs<ITestCaseFinished> args)
 {
     lock (executingTestCases)
     {
         executingTestCases.Remove(args.Message.TestCase);
         lastTestActivity = UtcNow;
     }
 }
 void HandleTestFailed(MessageHandlerArgs<ITestFailed> args)
 {
     var testFailed = args.Message;
     var testElement = CreateTestResultElement(testFailed, "Fail");
     testElement.Add(CreateFailureElement(testFailed));
 }
Пример #18
0
 /// <summary>
 /// Called when <see cref="TestMessageSink.TestAssemblyFinishedEvent"/> is raised.
 /// This signals the <see cref="Finished"/> event, which allows runners to know that
 /// execution is complete for this test assembly. Classes which override this method
 /// should be sure to do their work before calling this base version, if it is
 /// important that their work be done before the <see cref="Finished"/> event is signaled.
 /// </summary>
 protected virtual void HandleTestAssemblyFinished(MessageHandlerArgs <ITestAssemblyFinished> args)
 => Finished.Set();
 void HandleTestMethodCleanupFailure(MessageHandlerArgs<ITestMethodCleanupFailure> args)
     => AddError("test-method-cleanup", args.Message.TestMethod.Method.Name, args.Message);
Пример #20
0
 /// <summary>
 /// Called when <see cref="TestMessageSink.DiscoveryCompleteMessageEvent"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleDiscoveryCompleteMessage(MessageHandlerArgs <IDiscoveryCompleteMessage> args)
 => Finished.Set();
 void HandleTestPassed(MessageHandlerArgs<ITestPassed> args)
     => CreateTestResultElement(args.Message, "Pass");
 /// <summary>
 /// Called when <see cref="ITestExecutionSummary"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestExecutionSummary(MessageHandlerArgs <ITestExecutionSummary> args)
 => WriteDefaultSummary(Logger, args.Message);
 void HandleTestSkipped(MessageHandlerArgs<ITestSkipped> args)
 {
     var testSkipped = args.Message;
     var testElement = CreateTestResultElement(testSkipped, "Skip");
     testElement.Add(new XElement("reason", new XCData(XmlEscape(testSkipped.Reason))));
 }
Пример #24
0
 void HandleTestCaseCleanupFailure(MessageHandlerArgs <ITestCaseCleanupFailure> args)
 => AddError("test-case-cleanup", args.Message.TestCase.DisplayName, args.Message);
        /// <summary>
        /// Handles instances of <see cref="ITestPassed" />.
        /// </summary>
        protected virtual void HandleTestPassed(MessageHandlerArgs <ITestPassed> args)
        {
            var testPassed = args.Message;

            LogFinish(testPassed);
        }
Пример #26
0
 void HandleTestPassed(MessageHandlerArgs <ITestPassed> args)
 => CreateTestResultElement(args.Message, "Pass");
        /// <summary>
        /// Handles instances of <see cref="IErrorMessage" />.
        /// </summary>
        protected virtual void HandleErrorMessage(MessageHandlerArgs <IErrorMessage> args)
        {
            var error = args.Message;

            LogError("FATAL ERROR", error);
        }
 /// <summary>
 /// Called when <see cref="ITestPassed"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestPassed(MessageHandlerArgs<ITestPassed> args)
 {
     var testPassed = args.Message;
     if (!string.IsNullOrEmpty(testPassed.Output) &&
         GetExecutionOptions(testPassed.TestAssembly.Assembly.AssemblyPath).GetDiagnosticMessagesOrDefault())
     {
         lock (Logger.LockObject)
         {
             Logger.LogImportantMessage($"    {Escape(testPassed.Test.DisplayName)} [PASS]");
             LogOutput(StackFrameInfo.None, testPassed.Output);
         }
     }
 }
        /// <summary>
        /// Handles instances of <see cref="ITestAssemblyCleanupFailure" />.
        /// </summary>
        protected virtual void HandleTestAssemblyCleanupFailure(MessageHandlerArgs <ITestAssemblyCleanupFailure> args)
        {
            var cleanupFailure = args.Message;

            LogError($"Test Assembly Cleanup Failure ({cleanupFailure.TestAssembly.Assembly.AssemblyPath})", cleanupFailure);
        }
 void HandleTestCaseStarting(MessageHandlerArgs <ITestCaseStarting> args)
 {
     lock (executingTestCases)
         executingTestCases.Add(args.Message.TestCase, UtcNow);
 }
        /// <summary>
        /// Handles instances of <see cref="ITestClassCleanupFailure" />.
        /// </summary>
        protected virtual void HandleTestCaseCleanupFailure(MessageHandlerArgs <ITestClassCleanupFailure> args)
        {
            var cleanupFailure = args.Message;

            LogError($"Test Class Cleanup Failure ({cleanupFailure.TestClass.Class.Name})", cleanupFailure);
        }
 void HandleTestAssemblyStarting(MessageHandlerArgs <ITestAssemblyStarting> args)
 {
     stopEvent        = new ManualResetEvent(initialState: false);
     lastTestActivity = UtcNow;
     XunitWorkerThread.QueueUserWorkItem(ThreadWorker);
 }
        /// <summary>
        /// Handles instances of <see cref="ITestCollectionCleanupFailure" />.
        /// </summary>
        protected virtual void HandleTestCollectionCleanupFailure(MessageHandlerArgs <ITestCollectionCleanupFailure> args)
        {
            var cleanupFailure = args.Message;

            LogError($"Test Collection Cleanup Failure ({cleanupFailure.TestCollection.DisplayName})", cleanupFailure);
        }
 void HandleTestCaseStarting(MessageHandlerArgs<ITestCaseStarting> args)
 {
     lock (executingTestCases)
         executingTestCases.Add(args.Message.TestCase, UtcNow);
 }
        /// <summary>
        /// Handles instances of <see cref="ITestCollectionFinished" />.
        /// </summary>
        protected virtual void HandleTestCollectionFinished(MessageHandlerArgs <ITestCollectionFinished> args)
        {
            var testCollectionFinished = args.Message;

            logger.LogImportantMessage($"##teamcity[testSuiteFinished name='{Escape(displayNameFormatter.DisplayName(testCollectionFinished.TestCollection))}' flowId='{ToFlowId(testCollectionFinished.TestCollection.DisplayName)}']");
        }
 void HandleTestAssemblyStarting(MessageHandlerArgs<ITestAssemblyStarting> args)
 {
     stopEvent = new ManualResetEvent(initialState: false);
     lastTestActivity = UtcNow;
     XunitWorkerThread.QueueUserWorkItem(ThreadWorker);
 }
 /// <summary>
 /// Called when <see cref="IErrorMessage"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleErrorMessage(MessageHandlerArgs<IErrorMessage> args)
     => LogError("FATAL ERROR", args.Message);
Пример #38
0
 void HandleTestAssemblyStarting(MessageHandlerArgs <ITestAssemblyStarting> args)
 {
     cancellationTokenSource = new CancellationTokenSource();
     timerTask        = StartTimerAsync();
     lastTestActivity = UtcNow;
 }
        /// <summary>
        /// Called when <see cref="ITestAssemblyDiscoveryFinished"/> is raised.
        /// </summary>
        /// <param name="args">An object that contains the event data.</param>
        protected virtual void HandleTestAssemblyDiscoveryFinished(MessageHandlerArgs<ITestAssemblyDiscoveryFinished> args)
        {
            var discoveryFinished = args.Message;
            var assemblyDisplayName = GetAssemblyDisplayName(discoveryFinished.Assembly);

            if (discoveryFinished.DiscoveryOptions.GetDiagnosticMessagesOrDefault())
            {
                var count =
                    discoveryFinished.TestCasesToRun == discoveryFinished.TestCasesDiscovered
                        ? discoveryFinished.TestCasesDiscovered.ToString()
                        : $"{discoveryFinished.TestCasesToRun} of {discoveryFinished.TestCasesDiscovered}";

                Logger.LogImportantMessage($"  Discovered:  {assemblyDisplayName} (running {count} test case{(discoveryFinished.TestCasesToRun == 1 ? "" : "s")})");
            }
            else
                Logger.LogImportantMessage($"  Discovered:  {assemblyDisplayName}");
        }
Пример #40
0
 /// <summary>
 /// Called when <see cref="TestMessageSink.TestCaseDiscoveryMessageEvent"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestCaseDiscoveryMessage(MessageHandlerArgs <ITestCaseDiscoveryMessage> args)
 => TestCases.Add(args.Message.TestCase);
        /// <summary>
        /// Called when <see cref="ITestAssemblyDiscoveryStarting"/> is raised.
        /// </summary>
        /// <param name="args">An object that contains the event data.</param>
        protected virtual void HandleTestAssemblyDiscoveryStarting(MessageHandlerArgs<ITestAssemblyDiscoveryStarting> args)
        {
            var discoveryStarting = args.Message;
            var assemblyDisplayName = GetAssemblyDisplayName(discoveryStarting.Assembly);

            if (discoveryStarting.DiscoveryOptions.GetDiagnosticMessagesOrDefault())
            {
#if PLATFORM_DOTNET
                Logger.LogImportantMessage($"  Discovering: {assemblyDisplayName} (method display = {discoveryStarting.DiscoveryOptions.GetMethodDisplayOrDefault()})");
#else
                Logger.LogImportantMessage($"  Discovering: {assemblyDisplayName} (app domain = {(discoveryStarting.AppDomain ? $"on [{(discoveryStarting.ShadowCopy ? "shadow copy" : "no shadow copy")}]" : "off")}, method display = {discoveryStarting.DiscoveryOptions.GetMethodDisplayOrDefault()})");
#endif
            }
            else
                Logger.LogImportantMessage($"  Discovering: {assemblyDisplayName}");
        }
 /// <summary>
 /// Called when <see cref="IErrorMessage"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleErrorMessage(MessageHandlerArgs <IErrorMessage> args)
 => LogError("FATAL ERROR", args.Message);
        /// <summary>
        /// Called when <see cref="ITestAssemblyExecutionFinished"/> is raised.
        /// </summary>
        /// <param name="args">An object that contains the event data.</param>
        protected virtual void HandleTestAssemblyExecutionFinished(MessageHandlerArgs<ITestAssemblyExecutionFinished> args)
        {
            var executionFinished = args.Message;
            Logger.LogImportantMessage($"  Finished:    {GetAssemblyDisplayName(executionFinished.Assembly)}");

            RemoveExecutionOptions(executionFinished.Assembly.AssemblyFilename);
        }
 /// <summary>
 /// Called when <see cref="ITestCollectionCleanupFailure"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestCollectionCleanupFailure(MessageHandlerArgs <ITestCollectionCleanupFailure> args)
 => LogError($"Test Collection Cleanup Failure ({args.Message.TestCollection.DisplayName})", args.Message);
        /// <summary>
        /// Called when <see cref="ITestAssemblyExecutionStarting"/> is raised.
        /// </summary>
        /// <param name="args">An object that contains the event data.</param>
        protected virtual void HandleTestAssemblyExecutionStarting(MessageHandlerArgs<ITestAssemblyExecutionStarting> args)
        {
            var executionStarting = args.Message;
            AddExecutionOptions(executionStarting.Assembly.AssemblyFilename, executionStarting.ExecutionOptions);

            var assemblyDisplayName = GetAssemblyDisplayName(executionStarting.Assembly);

            if (executionStarting.ExecutionOptions.GetDiagnosticMessagesOrDefault())
            {
                var threadCount = executionStarting.ExecutionOptions.GetMaxParallelThreadsOrDefault();
                var threadCountText = threadCount < 0 ? "unlimited" : threadCount.ToString();
                Logger.LogImportantMessage($"  Starting:    {assemblyDisplayName} (parallel test collections = {(!executionStarting.ExecutionOptions.GetDisableParallelizationOrDefault() ? "on" : "off")}, max threads = {threadCountText})");
            }
            else
                Logger.LogImportantMessage($"  Starting:    {assemblyDisplayName}");
        }
 /// <summary>
 /// Called when <see cref="ITestMethodCleanupFailure"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestMethodCleanupFailure(MessageHandlerArgs <ITestMethodCleanupFailure> args)
 => LogError($"Test Method Cleanup Failure ({args.Message.TestMethod.Method.Name})", args.Message);
 /// <summary>
 /// Called when <see cref="ITestAssemblyCleanupFailure"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestAssemblyCleanupFailure(MessageHandlerArgs<ITestAssemblyCleanupFailure> args)
     => LogError($"Test Assembly Cleanup Failure ({args.Message.TestAssembly.Assembly.AssemblyPath})", args.Message);
Пример #48
0
 void HandleTestAssemblyCleanupFailure(MessageHandlerArgs <ITestAssemblyCleanupFailure> args)
 => AddError("assembly-cleanup", args.Message.TestAssembly.Assembly.AssemblyPath, args.Message);
 /// <summary>
 /// Called when <see cref="ITestCollectionCleanupFailure"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestCollectionCleanupFailure(MessageHandlerArgs<ITestCollectionCleanupFailure> args)
     => LogError($"Test Collection Cleanup Failure ({args.Message.TestCollection.DisplayName})", args.Message);
Пример #50
0
 void HandleTestClassCleanupFailure(MessageHandlerArgs <ITestClassCleanupFailure> args)
 => AddError("test-class-cleanup", args.Message.TestClass.Class.Name, args.Message);
 /// <summary>
 /// Called when <see cref="ITestExecutionSummary"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestExecutionSummary(MessageHandlerArgs<ITestExecutionSummary> args)
     => WriteDefaultSummary(Logger, args.Message);
Пример #52
0
 void HandleTestMethodCleanupFailure(MessageHandlerArgs <ITestMethodCleanupFailure> args)
 => AddError("test-method-cleanup", args.Message.TestMethod.Method.Name, args.Message);
        /// <summary>
        /// Called when <see cref="ITestFailed"/> is raised.
        /// </summary>
        /// <param name="args">An object that contains the event data.</param>
        protected virtual void HandleTestFailed(MessageHandlerArgs<ITestFailed> args)
        {
            var testFailed = args.Message;
            var frameInfo = StackFrameInfo.FromFailure(testFailed);

            lock (Logger.LockObject)
            {
                Logger.LogError(frameInfo, $"    {Escape(testFailed.Test.DisplayName)} [FAIL]");

                foreach (var messageLine in ExceptionUtility.CombineMessages(testFailed).Split(new[] { Environment.NewLine }, StringSplitOptions.None))
                    Logger.LogImportantMessage(frameInfo, $"      {messageLine}");

                LogStackTrace(frameInfo, ExceptionUtility.CombineStackTraces(testFailed));
                LogOutput(frameInfo, testFailed.Output);
            }
        }
 /// <summary>
 /// Called when <see cref="ITestMethodCleanupFailure"/> is raised.
 /// </summary>
 /// <param name="args">An object that contains the event data.</param>
 protected virtual void HandleTestMethodCleanupFailure(MessageHandlerArgs<ITestMethodCleanupFailure> args)
     => LogError($"Test Method Cleanup Failure ({args.Message.TestMethod.Method.Name})", args.Message);
 void HandleErrorMessage(MessageHandlerArgs<IErrorMessage> args)
     => AddError("fatal", null, args.Message);