Skip to content

feat(dotnet): add JUnit XML output, upgrade to .NET 8, and refactor to Calculator classes#101

Merged
Konboi merged 1 commit into
masterfrom
worktree-support-dotnet-junit
May 21, 2026
Merged

feat(dotnet): add JUnit XML output, upgrade to .NET 8, and refactor to Calculator classes#101
Konboi merged 1 commit into
masterfrom
worktree-support-dotnet-junit

Conversation

@Konboi

@Konboi Konboi commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Why

The dotnet example needed several improvements:

  • It only outputted NUnit XML format, but JUnit XML format was also needed for broader compatibility with test reporting tools.
  • The project was targeting .NET 7 which reached end-of-life in May 2024.
  • The sample code was a simple Example class that didn't clearly demonstrate how test reports look across multiple test classes.

What

  • Add JUnit XML output: Added JunitXml.TestLogger package and updated dotnet test command to output both test-result.xml (NUnit format) and junit-result.xml (JUnit format).
  • Upgrade to .NET 8 LTS: Updated TargetFramework to net8.0 and SDK version to 8.0.x in the CI workflow. Also updated all package versions to be compatible with .NET 8.
  • Refactor to Calculator classes: Replaced Example class with a proper Calculator structure:
    • Individual operation classes: AddCalculator, SubtractCalculator, MultiplyCalculator, DivideCalculator, PowerCalculator
    • A Calculator facade class that composes all operation classes
    • Separate test class per operation class to demonstrate how multiple test classes appear in the XML reports
  • Add intentional failing tests: Added TestAddFailing and TestDivideFailing with a comment indicating they are intentionally failing, to verify that failure reporting works correctly in both XML formats.

Please Review Here (Optional)

  • Package versions for NunitXml.TestLogger was bumped to 8.0.0 to fix a get_InputSanitizer interface compatibility error with the newer test platform (17.8.0).

…o Calculator classes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Assert.Throws<ArgumentException>(() => _calculator.Divide(10, 0));
}

// Intentionally failing test to verify failure reporting in test reports

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failed due to this intentional failed test

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.100

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet 7 is already EOL

@Konboi Konboi merged commit 463c82b into master May 21, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants