Table of Contents

Class TestIdentityGenerator

Namespace
Xping.Sdk.Core.Models
Assembly
Xping.Sdk.Core.dll

Generates stable, deterministic test identities for tracking tests across runs, environments, and code changes.

public static class TestIdentityGenerator
Inheritance
TestIdentityGenerator
Inherited Members

Remarks

This generator creates consistent TestId hashes that enable:

  • Tracking the same test across different environments (CI, local, Docker)
  • Monitoring test history across refactorings
  • Identifying parameterized test variations
  • Analyzing test reliability trends over time

The algorithm ensures:

  • Deterministic output (same input always produces same hash)
  • Cross-platform consistency (Windows, Linux, macOS)
  • .NET version independence
  • Collision resistance (using SHA256)

Methods

Generate(string, string, object[]?, string?, string?, int?)

Generates a complete test identity from test metadata.

public static TestIdentity Generate(string fullyQualifiedName, string assembly, object[]? parameters = null, string? displayName = null, string? sourceFile = null, int? sourceLineNumber = null)

Parameters

fullyQualifiedName string

The fully qualified test name (Namespace.Class.Method).

assembly string

The assembly name where the test is defined.

parameters object[]

Optional parameters for parameterized tests.

displayName string

Optional display name for human readability.

sourceFile string

Optional source file path.

sourceLineNumber int?

Optional source line number.

Returns

TestIdentity

A complete TestIdentity with stable TestId hash.

Exceptions

ArgumentNullException

Thrown when fullyQualifiedName or assembly is null.

ArgumentException

Thrown when fullyQualifiedName is invalid format.

GenerateErrorMessageHash(string?)

Generates a stable SHA256 hash for an error message to enable grouping of similar failures.

public static string? GenerateErrorMessageHash(string? errorMessage)

Parameters

errorMessage string

The error message to hash.

Returns

string

A 64-character lowercase hex string (SHA256 hash), or null if input is null/empty.

Remarks

This method creates a stable hash that can be used to group test failures with identical error messages, enabling analysis of failure patterns across test runs.

GenerateParameterHash(object[])

Generates a stable hash from test parameters.

public static string GenerateParameterHash(object[] parameters)

Parameters

parameters object[]

The test parameters.

Returns

string

A canonical string representation of the parameters.

Remarks

Parameter handling:

  • Null values: "null"
  • Numbers: Invariant culture formatting
  • Strings: Direct value
  • DateTime: ISO 8601 format (yyyy-MM-ddTHH:mm:ss.fffffffZ)
  • Arrays/Collections: Recursive formatting with square brackets
  • Objects: Type name + ToString()

Examples:

  • [2, 3, 5] → "2,3,5"
  • ["hello", null, 42] → "hello,null,42"
  • [new int[] {1, 2}, "test"] → "[1,2],test"

GenerateStackTraceHash(string?)

Generates a stable SHA256 hash for a stack trace to enable grouping of similar failures.

public static string? GenerateStackTraceHash(string? stackTrace)

Parameters

stackTrace string

The stack trace to hash.

Returns

string

A 64-character lowercase hex string (SHA256 hash), or null if input is null/empty.

Remarks

This method creates a stable hash that can be used to group test failures with identical stack traces, enabling analysis of failure locations and patterns in the codebase.

GenerateTestId(string, string?)

Generates a stable SHA256 hash for a test identifier.

public static string GenerateTestId(string fullyQualifiedName, string? parameterHash = null)

Parameters

fullyQualifiedName string

The fully qualified test name.

parameterHash string

Optional parameter hash for parameterized tests.

Returns

string

A 64-character lowercase hex string (SHA256 hash).

Remarks

The hash is computed from: "{fullyQualifiedName}|{parameterHash}" The pipe separator ensures distinct hashes for tests with/without parameters.