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
-
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=$ExecutionIdset $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 -
There is nothing built-in to do this, but you could do this with a custom variable function.
-
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); } } -
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