Class TestIdentity
Represents a stable, deterministic identity for a test that persists across:
- Different machines and environments (CI, local, Docker)
- Different .NET versions
- Code refactorings and minor formatting changes
- Parameterized test variations
public sealed class TestIdentity
- Inheritance
-
TestIdentity
- Inherited Members
Remarks
The TestId is a SHA256 hash computed from the fully qualified name and parameters, ensuring the same test always generates the same ID regardless of execution context. This enables reliable test tracking and historical analysis across test runs.
Properties
Assembly
Gets or sets the assembly name where the test is defined.
public string Assembly { get; set; }
Property Value
Remarks
Example: "MyApp.Tests"
ClassName
Gets or sets the class name where the test method is defined.
public string ClassName { get; set; }
Property Value
Remarks
Example: "CalculatorTests"
DisplayName
Gets or sets the display name for human readability. This is the name shown in test runners and reports.
public string? DisplayName { get; set; }
Property Value
Remarks
Example: "Add_ReturnSum(a: 2, b: 3, expected: 5)" May include parameter names and values for better readability.
FullyQualifiedName
Gets or sets the fully qualified name of the test. Format: Namespace.ClassName.MethodName
public string FullyQualifiedName { get; set; }
Property Value
Remarks
Example: "MyApp.Tests.CalculatorTests.Add_ReturnSum" This may change during refactoring, but TestId remains stable.
MethodName
Gets or sets the test method name.
public string MethodName { get; set; }
Property Value
Remarks
Example: "Add_ReturnSum"
Namespace
Gets or sets the namespace where the test is defined.
public string Namespace { get; set; }
Property Value
Remarks
Example: "MyApp.Tests"
ParameterHash
Gets or sets the parameter hash for parameterized tests. Null for non-parameterized tests.
public string? ParameterHash { get; set; }
Property Value
Remarks
For parameterized tests (xUnit [Theory], NUnit [TestCase], MSTest [DataRow]), this contains a stable hash of the parameter values. Example: "2,3,5" for Add_ReturnSum(2, 3, 5)
Format: Comma-separated string representation of parameters.
SourceFile
Gets or sets the source file path where the test is defined. Optional, useful for IDE navigation and debugging.
public string? SourceFile { get; set; }
Property Value
SourceLineNumber
Gets or sets the line number in the source file where the test begins. Optional, useful for IDE navigation and debugging.
public int? SourceLineNumber { get; set; }
Property Value
- int?
TestId
Gets or sets the stable test identifier (SHA256 hash of FQN + parameters). This ID remains constant for the same test across all environments and runs.
public string TestId { get; set; }
Property Value
Remarks
Format: SHA256 hash as lowercase hex string (64 characters). Example: "a3f5e9c2d1b4a7f8e0c9d6b3a2f1e8d5c7b4a9f6e3d0c8b5a2f9e6d3c0b7a4f1"