TUnit Fixes & Improvements - #677
Conversation
Cross-referenced against tunit.dev/llms.txt and the official attributes comparison page. Corrects the test class marker (TUnit is convention-based, not [ClassDataSource]), and fills in the previously-missing TUnit rows for the assertion APIs, setup/teardown methods, exception-handling examples, and integration test category marker.
The Type row's TUnit cell now uses IsAssignableTo<T>() to match the
assignable-type semantics of the MSTest/xUnit/NUnit equivalents, with a
note pointing at IsTypeOf<T>() for exact-type checks. The Skip row now
documents that [Skip] also applies at class and assembly scope and that
Skip.Test("reason") handles dynamic in-test skipping.
Verified against the TUnit migration guides and the type-assertions docs.
There was a problem hiding this comment.
Pull request overview
This PR updates the .NET test framework reference material to correct/expand TUnit guidance (detection markers, assertion APIs, skipping, and lifecycle hooks), and modernizes the TUnit test fixture project used by the dotnet-test run-tests scenarios.
Changes:
- Update the TUnit fixture project to target
net10.0and use a newerTUnitpackage version. - Expand
dotnet-test-frameworksreference tables and examples to include TUnit assertion APIs, skipping behavior, and setup/teardown hooks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/dotnet-test/run-tests/fixtures/mtp-tunit/TestProject.csproj | Updates the TUnit fixture to net10.0 and bumps the TUnit package version. |
| plugins/dotnet-test/skills/dotnet-test-frameworks/SKILL.md | Fixes/extends TUnit documentation in framework reference tables and adds TUnit-specific guidance/examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The Boolean, Null, Exception, and Type rows in the assertions table previously used a `await Assert.That(x).IsTrue()` / `.IsFalse()` shorthand for the alternative form. A reader copy-pasting just the second fragment would end up with an un-awaited assertion that silently passes — which contradicts the note immediately below the table about always awaiting. Each alternative is now a complete, independently copy-pasteable expression. Addresses the inline review on dotnet#677.
|
Thanks @thomhurst! Let me see if we need some extra work on eval for the newly added info |
|
/evaluate |
Skill Validation Results
[1] (Plugin) Quality unchanged but weighted score is -2.6% due to: tokens (12931 → 17866), time (11.9s → 15.1s)
Model: claude-opus-4.6 | Judge: claude-opus-4.6 🔍 Full Results - additional metrics and failure investigation steps ▶ Sessions Visualisation -- interactive replay of all evaluation sessions |
|
@thomhurst do you mind adding some evals (copilot is good at helping) to validate that the TUnit instructions are actually helping LLM? |
* Add TUnit-focused eval scenarios for dotnet-test-frameworks Adds 5 new evaluation scenarios and tightens 2 existing scenarios to exercise the expanded TUnit coverage in dotnet-test-frameworks/SKILL.md (see #677). New scenarios: - Convert cross-framework assertions to TUnit syntax (await / IsEqualTo / IsTrue / IsNull / IsAssignableTo / Contains / Throws<T>) - Diagnose silently-passing TUnit test with missing await (debugging mystery framed without naming the pitfall) - Refactor TUnit try/catch to native exception assertion (Throws<T>() / ThrowsExactly<T>() / WithMessage) - TUnit lifecycle hooks at test / class / assembly / session scope - TUnit skip mechanisms — attribute, assembly-wide [assembly: Skip], and dynamic Skip.Test(...) Updated scenarios: - Identify TUnit framework: rubric now distinguishes [ClassDataSource] as a fixture/data source rather than a class marker (TUnit classes are convention-based, like xUnit) - Identify integration tests: adds a TUnit Project D using live SqlConnection and requires recommending [Category("Integration")] for TUnit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Mirror TUnit eval scenarios into Vally spec Apply the same updated and new scenarios as in eval.yaml to the parallel eval.vally.yaml so both pipelines exercise the new TUnit-focused checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Amaury Levé <amauryleve@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/evaluate |
Skill Validation Results
[1]
Model: claude-opus-4.6 | Judge: claude-opus-4.6 🔍 Full Results - additional metrics and failure investigation steps
▶ Sessions Visualisation -- interactive replay of all evaluation sessions |
Some docs for TUnit was either wrong, or missing in comparison tables, so these have been fixed.
Also updated the example project to a modern version.
Also added some other useful bits to know too.