Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Unit Tests Results Summary

    Scheduled Pinned Locked Moved Support
    nunitunit-testsbuildmastermstest
    4 Posts 1 Posters 5 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? This user is from outside of this forum
      Guest
      last edited by

      We have an execution plan whose job it is to execute a number of unit tests across a range of test projects.

      On completion of the tests, we're currently posting out a notification which contains a link to the test-results page as follows:

      set $TestResultsUrl = http://ourbuildserver/executions/test-results?executionId=$ExecutionId

      set $testsCompletedNotifcationMessage = $ApplicationName - $ReleaseName finished executing\n<$TestResultsUrl|Results>;

      Is there a system variable or function for getting the actually results summary (as presented on the test-results page) within the execution context so we can include it in the notification message body too?

      Product: BuildMaster
      Version: 5.6.8

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        There is nothing built-in to do this, but you could do this with a custom variable function.

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          Thanks Alex,

          As recommended, I've created a variable function extension for this, which has worked perfectly:

            [ScriptAlias("TestResultsSummary")]
            [Description("Returns a test results summary string for the execution in the current scope.")]
            [Category("Unit Testing")]
            public class TestResultsSummaryVariableFunction : ScalarVariableFunction
            {
              [DisplayName("executionId")]
              [Description("The ID of the execution whose test results summary will be returned. If empty, the execution ID "
                     + "in the current context will be used.")]
              [VariableFunctionParameter(0, Optional = true)]
              public int? ExecutionId { get; set; }
          
              protected override object EvaluateScalar(IGenericBuildMasterContext context)
              {
                int? executionId = this.ExecutionId ?? context.ExecutionId;
          
                if (executionId == null || executionId <= 0)
                  return "INVALID EXECUTION ID";
          
                var testResults = DB.BuildTestResults_GetTestResults(executionId);
          
                var runCount = testResults.Count;
                var passCount = 0;
                var failCount = 0;
                var inconclusiveCount = 0;
          
                foreach (var result in testResults)
                {
                  if (result.TestStatus_Code == Domains.TestStatusCodes.Passed)
                    passCount++;
          
                  if (result.TestStatus_Code == Domains.TestStatusCodes.Failed)
                    failCount++;
          
                  if (result.TestStatus_Code == Domains.TestStatusCodes.Inconclusive)
                    inconclusiveCount++;
                }
          
                return string.Format("{0} run, {1} passed, {2} failed, {3} inconclusive", runCount, passCount, failCount, inconclusiveCount);
              }
            }
          
          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

            For re-use:

            https://github.com/rockpooldigital/bmx-testresultssummary

            Cheers again,

            Jamie

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation