Skip to content

Commit

Permalink
Add test run name and hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Jandini committed Oct 14, 2023
1 parent 62d312c commit 5109939
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/KiBoards.Xunit/TestFramework.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using KiBoards.Services;
using Xunit.Abstractions;
using Xunit.Sdk;
Expand Down Expand Up @@ -109,6 +111,12 @@ private class TestClassRunner : XunitTestClassRunner
public TestClassRunner(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable<IXunitTestCase> testCases, IMessageSink diagnosticMessageSink, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, IDictionary<Type, object> 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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/KiBoards.Xunit/TestRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit 5109939

Please sign in to comment.