{"kind":"Skill","metadata":{"namespace":"community","name":"csharp-tunit","version":"0.1.0"},"spec":{"description":"Get best practices for TUnit unit testing, including data-driven tests","files":{"SKILL.md":"---\nname: csharp-tunit\ndescription: 'Get best practices for TUnit unit testing, including data-driven tests'\n---\n\n# TUnit Best Practices\n\nYour goal is to help me write effective unit tests with TUnit, covering both standard and data-driven testing approaches.\n\n## Project Setup\n\n- Use a separate test project with naming convention `[ProjectName].Tests`\n- Reference TUnit package and TUnit.Assertions for fluent assertions\n- Create test classes that match the classes being tested (e.g., `CalculatorTests` for `Calculator`)\n- Use .NET SDK test commands: `dotnet test` for running tests\n- TUnit requires .NET 8.0 or higher\n\n## Test Structure\n\n- No test class attributes required (like xUnit/NUnit)\n- Use `[Test]` attribute for test methods (not `[Fact]` like xUnit)\n- Follow the Arrange-Act-Assert (AAA) pattern\n- Name tests using the pattern `MethodName_Scenario_ExpectedBehavior`\n- Use lifecycle hooks: `[Before(Test)]` for setup and `[After(Test)]` for teardown\n- Use `[Before(Class)]` and `[After(Class)]` for shared context between tests in a class\n- Use `[Before(Assembly)]` and `[After(Assembly)]` for shared context across test classes\n- TUnit supports advanced lifecycle hooks like `[Before(TestSession)]` and `[After(TestSession)]`\n\n## Standard Tests\n\n- Keep tests focused on a single behavior\n- Avoid testing multiple behaviors in one test method\n- Use TUnit's fluent assertion syntax with `await Assert.That()`\n- Include only the assertions needed to verify the test case\n- Make tests independent and idempotent (can run in any order)\n- Avoid test interdependencies (use `[DependsOn]` attribute if needed)\n\n## Data-Driven Tests\n\n- Use `[Arguments]` attribute for inline test data (equivalent to xUnit's `[InlineData]`)\n- Use `[MethodData]` for method-based test data (equivalent to xUnit's `[MemberData]`)\n- Use `[ClassData]` for class-based test data\n- Create custom data sources by implementing `ITestDataSource`\n- Use meaningful parameter names in data-driven tests\n- Multiple `[Arguments]` attributes can be applied to the same test method\n\n## Assertions\n\n- Use `await Assert.That(value).IsEqualTo(expected)` for value equality\n- Use `await Assert.That(value).IsSameReferenceAs(expected)` for reference equality\n- Use `await Assert.That(value).IsTrue()` or `await Assert.That(value).IsFalse()` for boolean conditions\n- Use `await Assert.That(collection).Contains(item)` or `await Assert.That(collection).DoesNotContain(item)` for collections\n- Use `await Assert.That(value).Matches(pattern)` for regex pattern matching\n- Use `await Assert.That(action).Throws\u003cTException\u003e()` or `await Assert.That(asyncAction).ThrowsAsync\u003cTException\u003e()` to test exceptions\n- Chain assertions with `.And` operator: `await Assert.That(value).IsNotNull().And.IsEqualTo(expected)`\n- Use `.Or` operator for alternative conditions: `await Assert.That(value).IsEqualTo(1).Or.IsEqualTo(2)`\n- Use `.Within(tolerance)` for DateTime and numeric comparisons with tolerance\n- All assertions are asynchronous and must be awaited\n\n## Advanced Features\n\n- Use `[Repeat(n)]` to repeat tests multiple times\n- Use `[Retry(n)]` for automatic retry on failure\n- Use `[ParallelLimit\u003cT\u003e]` to control parallel execution limits\n- Use `[Skip(\"reason\")]` to skip tests conditionally\n- Use `[DependsOn(nameof(OtherTest))]` to create test dependencies\n- Use `[Timeout(milliseconds)]` to set test timeouts\n- Create custom attributes by extending TUnit's base attributes\n\n## Test Organization\n\n- Group tests by feature or component\n- Use `[Category(\"CategoryName\")]` for test categorization\n- Use `[DisplayName(\"Custom Test Name\")]` for custom test names\n- Consider using `TestContext` for test diagnostics and information\n- Use conditional attributes like custom `[WindowsOnly]` for platform-specific tests\n\n## Performance and Parallel Execution\n\n- TUnit runs tests in parallel by default (unlike xUnit which requires explicit configuration)\n- Use `[NotInParallel]` to disable parallel execution for specific tests\n- Use `[ParallelLimit\u003cT\u003e]` with custom limit classes to control concurrency\n- Tests within the same class run sequentially by default\n- Use `[Repeat(n)]` with `[ParallelLimit\u003cT\u003e]` for load testing scenarios\n\n## Migration from xUnit\n\n- Replace `[Fact]` with `[Test]`\n- Replace `[Theory]` with `[Test]` and use `[Arguments]` for data\n- Replace `[InlineData]` with `[Arguments]`\n- Replace `[MemberData]` with `[MethodData]`\n- Replace `Assert.Equal` with `await Assert.That(actual).IsEqualTo(expected)`\n- Replace `Assert.True` with `await Assert.That(condition).IsTrue()`\n- Replace `Assert.Throws\u003cT\u003e` with `await Assert.That(action).Throws\u003cT\u003e()`\n- Replace constructor/IDisposable with `[Before(Test)]`/`[After(Test)]`\n- Replace `IClassFixture\u003cT\u003e` with `[Before(Class)]`/`[After(Class)]`\n\n**Why TUnit over xUnit?**\n\nTUnit offers a modern, fast, and flexible testing experience with advanced features not present in xUnit, such as asynchronous assertions, more refined lifecycle hooks, and improved data-driven testing capabilities. TUnit's fluent assertions provide clearer and more expressive test validation, making it especially suitable for complex .NET projects.\n"},"import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/tree/541b7819d8c3545c6df122491af4fa1eae415779/plugins/csharp-dotnet-development/skills/csharp-tunit"}},"content_hash":[32,183,181,55,178,119,163,115,242,199,100,53,183,239,152,154,250,33,234,126,152,60,23,171,6,100,44,25,122,113,182,38],"trust_level":"unsigned","yanked":false}
