From 51099391de1015eeb78bc71a30eff52e051eb686 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 14 Oct 2023 20:51:15 +0100 Subject: [PATCH] Add test run name and hash --- src/KiBoards.Xunit/TestFramework.cs | 8 ++++++++ src/KiBoards.Xunit/TestRun.cs | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/KiBoards.Xunit/TestFramework.cs b/src/KiBoards.Xunit/TestFramework.cs index 8167b06..de3b6c3 100644 --- a/src/KiBoards.Xunit/TestFramework.cs +++ b/src/KiBoards.Xunit/TestFramework.cs @@ -1,4 +1,6 @@ using System.Reflection; +using System.Security.Cryptography; +using System.Text; using KiBoards.Services; using Xunit.Abstractions; using Xunit.Sdk; @@ -109,6 +111,12 @@ private class TestClassRunner : XunitTestClassRunner public TestClassRunner(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable testCases, IMessageSink diagnosticMessageSink, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, IDictionary collectionFixtureMappings, KiBoardsTestRunner testRunner) : base(testClass, @class, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource, collectionFixtureMappings) { + var name = string.Join(",", testCases.Select(a => Path.GetFileNameWithoutExtension(a.TestMethod.TestClass.Class.Assembly.AssemblyPath)).Distinct()); + var md5 = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(string.Join(",", testCases.OrderBy(a => a.UniqueID).Select(a => a.UniqueID)))); + + TestRun.Name = name; + TestRun.Hash = BitConverter.ToString(md5).Replace("-", "").ToLower(); + _testRunner = testRunner; } diff --git a/src/KiBoards.Xunit/TestRun.cs b/src/KiBoards.Xunit/TestRun.cs index 4e79ade..14c95f7 100644 --- a/src/KiBoards.Xunit/TestRun.cs +++ b/src/KiBoards.Xunit/TestRun.cs @@ -5,6 +5,8 @@ namespace KiBoards public class TestRun { public string Id { get; internal set; } + public string Name { get; internal set; } + public string Hash { get; internal set; } public DateTime StartTime { get; internal set; } public string MachineName { get; internal set; } public string UserName { get; internal set; }