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
18 changes: 3 additions & 15 deletions .reviewmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,8 @@ reviews:
title: Review of TestResults IO Subsystem
paths:
- "docs/reqstream/test-results/io/io.yaml"
- "docs/reqstream/test-results/io/serializer.yaml"
- "docs/reqstream/test-results/io/trx-serializer.yaml"
- "docs/reqstream/test-results/io/junit-serializer.yaml"
- "docs/design/test-results/io/io.md"
- "docs/design/test-results/io/serializer.md"
- "docs/design/test-results/io/trx-serializer.md"
- "docs/design/test-results/io/junit-serializer.md"
- "src/DemaConsulting.TestResults/IO/Serializer.cs"
- "src/DemaConsulting.TestResults/IO/SerializerHelpers.cs"
- "src/DemaConsulting.TestResults/IO/TrxSerializer.cs"
- "src/DemaConsulting.TestResults/IO/JUnitSerializer.cs"
- "test/DemaConsulting.TestResults.Tests/IO/SerializerTests.cs"
- "test/DemaConsulting.TestResults.Tests/IO/TrxSerializerTests.cs"
- "test/DemaConsulting.TestResults.Tests/IO/TrxExampleTests.cs"
- "test/DemaConsulting.TestResults.Tests/IO/JUnitSerializerTests.cs"
- "test/DemaConsulting.TestResults.Tests/TestHelpers.cs"
- "test/DemaConsulting.TestResults.Tests/IO/IOTests.cs"

- id: TestResults-TestOutcome
title: Review of TestResults TestOutcome Unit
Expand Down Expand Up @@ -99,6 +85,7 @@ reviews:
- "src/DemaConsulting.TestResults/IO/Serializer.cs"
- "src/DemaConsulting.TestResults/IO/SerializerHelpers.cs"
- "test/DemaConsulting.TestResults.Tests/IO/SerializerTests.cs"
- "test/DemaConsulting.TestResults.Tests/TestHelpers.cs"

- id: TestResults-IO-TrxSerializer
title: Review of TestResults IO TrxSerializer Unit
Expand All @@ -108,6 +95,7 @@ reviews:
- "src/DemaConsulting.TestResults/IO/TrxSerializer.cs"
- "test/DemaConsulting.TestResults.Tests/IO/TrxSerializerTests.cs"
- "test/DemaConsulting.TestResults.Tests/IO/TrxExampleTests.cs"
- "test/DemaConsulting.TestResults.Tests/TestHelpers.cs"

- id: TestResults-IO-JUnitSerializer
title: Review of TestResults IO JUnitSerializer Unit
Expand Down
142 changes: 142 additions & 0 deletions test/DemaConsulting.TestResults.Tests/IO/IOTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Copyright(c) 2025 DEMA Consulting
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using DemaConsulting.TestResults.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DemaConsulting.TestResults.Tests.IO;

/// <summary>
/// Tests for the IO subsystem
/// </summary>
[TestClass]
public sealed class IOTests
{
/// <summary>
/// Test that the IO subsystem can identify TRX content
/// </summary>
/// <remarks>
/// Tests that the IO subsystem correctly identifies TRX-format content.
/// Proves that the subsystem can distinguish TRX from other formats.
/// </remarks>
[TestMethod]
public void IO_Identify_TrxContent_ReturnsTrx()
{
// Arrange - Minimal TRX content
const string content = """
<?xml version="1.0"?>
<TestRun xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" />
""";

// Act
var format = Serializer.Identify(content);

// Assert
Assert.AreEqual(TestResultFormat.Trx, format);
}

/// <summary>
/// Test that the IO subsystem can identify JUnit content
/// </summary>
/// <remarks>
/// Tests that the IO subsystem correctly identifies JUnit-format content.
/// Proves that the subsystem can distinguish JUnit from other formats.
/// </remarks>
[TestMethod]
public void IO_Identify_JUnitContent_ReturnsJUnit()
{
// Arrange - Minimal JUnit content
const string content = "<testsuites />";

// Act
var format = Serializer.Identify(content);

// Assert
Assert.AreEqual(TestResultFormat.JUnit, format);
}

/// <summary>
/// Test that the IO subsystem can deserialize TRX content
/// </summary>
/// <remarks>
/// Tests that the IO subsystem correctly deserializes TRX-format content into TestResults.
/// Proves that the subsystem end-to-end flow works for TRX files.
/// </remarks>
[TestMethod]
public void IO_Deserialize_TrxContent_ReturnsTestResults()
{
// Arrange - Minimal TRX content with one test result
const string content = """
<?xml version="1.0"?>
<TestRun xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" id="da21858f-2c78-442a-8ea6-51fe73762e0e" name="Test Run" runUser="User">
<Results>
<UnitTestResult testId="12345678-1234-1234-1234-123456789abc" testName="Test1" outcome="Passed" executionId="87654321-4321-4321-4321-cba987654321" computerName="TestComputer" testType="13CDC9D9-DDB5-4fa4-A97D-D965CCFC6D4B" duration="00:00:01" startTime="2025-01-01T00:00:00.000Z" endTime="2025-01-01T00:00:01.000Z" testListId="19431567-8539-422a-85D7-44EE4E166BDA">
<Output />
</UnitTestResult>
</Results>
<TestDefinitions>
<UnitTest name="Test1" id="12345678-1234-1234-1234-123456789abc">
<Execution id="87654321-4321-4321-4321-cba987654321" />
<TestMethod codeBase="TestAssembly" className="TestClass" name="Test1" />
</UnitTest>
</TestDefinitions>
</TestRun>
""";

// Act
var results = Serializer.Deserialize(content);

// Assert
Assert.IsNotNull(results);
Assert.HasCount(1, results.Results);
Assert.AreEqual("Test1", results.Results[0].Name);
Assert.AreEqual(TestOutcome.Passed, results.Results[0].Outcome);
}

/// <summary>
/// Test that the IO subsystem can deserialize JUnit content
/// </summary>
/// <remarks>
/// Tests that the IO subsystem correctly deserializes JUnit-format content into TestResults.
/// Proves that the subsystem end-to-end flow works for JUnit files.
/// </remarks>
[TestMethod]
public void IO_Deserialize_JUnitContent_ReturnsTestResults()
{
// Arrange - Minimal JUnit content with one test result
const string content = """
<?xml version="1.0"?>
<testsuites name="MySuite">
<testsuite name="MyClass" tests="1" failures="0" errors="0">
<testcase name="Test1" classname="MyClass" time="1.0" />
</testsuite>
</testsuites>
""";

// Act
var results = Serializer.Deserialize(content);

// Assert
Assert.IsNotNull(results);
Assert.HasCount(1, results.Results);
Assert.AreEqual("Test1", results.Results[0].Name);
Assert.AreEqual(TestOutcome.Passed, results.Results[0].Outcome);
}
}
Loading