Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .reviewmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ reviews:
title: Review of All TestResults Requirements
paths:
- "requirements.yaml"
- "docs/reqstream/**/*.yaml"
- "docs/reqstream/test-results/**/*.yaml"

- id: TestResults-IO
title: Review of TestResults IO Subsystem
Expand Down
2 changes: 1 addition & 1 deletion docs/design/test-results/io/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The IO subsystem depends on:
## Related Requirements

Requirements for the IO subsystem are in
[docs/reqstream/test-results/io/](../../reqstream/test-results/io/).
[docs/reqstream/test-results/io/](../../../reqstream/test-results/io/).
3 changes: 3 additions & 0 deletions src/DemaConsulting.TestResults/TestOutcome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static class TestOutcomeExtensions
/// <returns>True if the outcome indicates a pass</returns>
public static bool IsPassed(this TestOutcome outcome)
{
// Treat outcomes where the test logic completed without failure as passed
return outcome switch
{
TestOutcome.Passed => true,
Expand All @@ -124,6 +125,7 @@ public static bool IsPassed(this TestOutcome outcome)
/// <returns>True if the outcome indicates a fail</returns>
public static bool IsFailed(this TestOutcome outcome)
{
// Treat outcomes representing an abnormal termination or assertion failure as failed
return outcome switch
{
TestOutcome.Failed => true,
Expand All @@ -141,6 +143,7 @@ public static bool IsFailed(this TestOutcome outcome)
/// <returns>True if the outcome indicates the test was executed</returns>
public static bool IsExecuted(this TestOutcome outcome)
{
// Treat outcomes where the test was never attempted as not executed
return outcome switch
{
TestOutcome.NotRunnable => false,
Expand Down
50 changes: 37 additions & 13 deletions src/DemaConsulting.TestResults/TestResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,68 +25,92 @@ namespace DemaConsulting.TestResults;
/// </summary>
public sealed class TestResult
{
// Identity properties — each result needs unique IDs for cross-referencing
// between the test definition and its execution record

/// <summary>
/// Gets or sets the ID of the test case
/// Gets or sets the ID of the test case.
/// Defaults to a newly generated <see cref="Guid" /> so every test definition is uniquely identifiable.
/// </summary>
public Guid TestId { get; set; } = Guid.NewGuid();

/// <summary>
/// Gets or sets the ID of the test execution
/// Gets or sets the ID of the test execution.
/// Defaults to a newly generated <see cref="Guid" /> so every execution is uniquely identifiable.
/// </summary>
public Guid ExecutionId { get; set; } = Guid.NewGuid();

// Descriptive metadata — human-readable strings that identify the test in reports

/// <summary>
/// Gets or sets the name of the test case
/// Gets or sets the name of the test case.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the test code assembly
/// Gets or sets the test code assembly.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string CodeBase { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the name of the class containing the test case
/// Gets or sets the name of the class containing the test case.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string ClassName { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the name of the computer that executed the test case
/// Gets or sets the name of the computer that executed the test case.
/// Defaults to <see cref="Environment.MachineName" /> so locally-run results are attributed correctly.
/// </summary>
public string ComputerName { get; set; } = Environment.MachineName;

// Timing properties — record when and how long the test ran

/// <summary>
/// Gets or sets the start time of the test execution
/// Gets or sets the start time of the test execution.
/// Defaults to <see cref="DateTime.UtcNow" /> at construction time so ad-hoc results have a meaningful timestamp.
/// </summary>
public DateTime StartTime { get; set; } = DateTime.UtcNow;

/// <summary>
/// Gets or sets the duration of the test execution
/// Gets or sets the duration of the test execution.
/// Defaults to <see cref="TimeSpan.Zero" /> so the property is always valid even when timing is unavailable.
/// </summary>
public TimeSpan Duration { get; set; } = TimeSpan.Zero;

// Output capture — text written to stdout/stderr during the test run

/// <summary>
/// Gets or sets the stdout output when executing the test case
/// Gets or sets the stdout output when executing the test case.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string SystemOutput { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the stderr output when executing the test case
/// Gets or sets the stderr output when executing the test case.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string SystemError { get; set; } = string.Empty;

// Result properties — the outcome and any failure details

/// <summary>
/// Gets or sets the outcome of the test case
/// Gets or sets the outcome of the test case.
/// Defaults to <see cref="TestOutcome.NotExecuted" /> so a result that was never run is not mistaken for a pass.
/// </summary>
public TestOutcome Outcome { get; set; } = TestOutcome.NotExecuted;

/// <summary>
/// Gets or sets the test case error message
/// Gets or sets the test case error message.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string ErrorMessage { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the test case error stack trace
/// Gets or sets the test case error stack trace.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string ErrorStackTrace { get; set; } = string.Empty;
}
16 changes: 12 additions & 4 deletions src/DemaConsulting.TestResults/TestResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,31 @@ namespace DemaConsulting.TestResults;
/// </summary>
public sealed class TestResults
{
// Identity and metadata — unique identifier and human-readable name for the run

/// <summary>
/// Gets or sets the ID of the test results
/// Gets or sets the ID of the test results.
/// Defaults to a newly generated <see cref="Guid" /> so every test run is uniquely identifiable.
/// </summary>
public Guid Id { get; set; } = Guid.NewGuid();

/// <summary>
/// Gets or sets the name of the tests
/// Gets or sets the name of the tests.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the name of the user account running the tests
/// Gets or sets the name of the user account running the tests.
/// Defaults to <see cref="string.Empty" /> so the property is always non-null.
/// </summary>
public string UserName { get; set; } = string.Empty;

// Results collection — the ordered list of individual test outcomes for this run

/// <summary>
/// Gets or sets the list containing each TestResult
/// Gets or sets the list containing each <see cref="TestResult" />.
/// Defaults to an empty list so callers can add results without null-checking first.
/// </summary>
public List<TestResult> Results { get; set; } = [];
}
Loading
Loading