{"kind":"Skill","metadata":{"namespace":"community","name":"csharp-xunit","version":"0.1.0"},"spec":{"description":"Get best practices for XUnit unit testing, including data-driven tests","files":{"SKILL.md":"---\nname: csharp-xunit\ndescription: 'Get best practices for XUnit unit testing, including data-driven tests'\n---\n\n# XUnit Best Practices\n\nYour goal is to help me write effective unit tests with XUnit, 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 Microsoft.NET.Test.Sdk, xunit, and xunit.runner.visualstudio packages\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\n## Test Structure\n\n- No test class attributes required (unlike MSTest/NUnit)\n- Use fact-based tests with `[Fact]` attribute for simple tests\n- Follow the Arrange-Act-Assert (AAA) pattern\n- Name tests using the pattern `MethodName_Scenario_ExpectedBehavior`\n- Use constructor for setup and `IDisposable.Dispose()` for teardown\n- Use `IClassFixture\u003cT\u003e` for shared context between tests in a class\n- Use `ICollectionFixture\u003cT\u003e` for shared context between multiple test classes\n\n## Standard Tests\n\n- Keep tests focused on a single behavior\n- Avoid testing multiple behaviors in one test method\n- Use clear assertions that express intent\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\n\n## Data-Driven Tests\n\n- Use `[Theory]` combined with data source attributes\n- Use `[InlineData]` for inline test data\n- Use `[MemberData]` for method-based test data\n- Use `[ClassData]` for class-based test data\n- Create custom data attributes by implementing `DataAttribute`\n- Use meaningful parameter names in data-driven tests\n\n## Assertions\n\n- Use `Assert.Equal` for value equality\n- Use `Assert.Same` for reference equality\n- Use `Assert.True`/`Assert.False` for boolean conditions\n- Use `Assert.Contains`/`Assert.DoesNotContain` for collections\n- Use `Assert.Matches`/`Assert.DoesNotMatch` for regex pattern matching\n- Use `Assert.Throws\u003cT\u003e` or `await Assert.ThrowsAsync\u003cT\u003e` to test exceptions\n- Use fluent assertions library for more readable assertions\n\n## Mocking and Isolation\n\n- Consider using Moq or NSubstitute alongside XUnit\n- Mock dependencies to isolate units under test\n- Use interfaces to facilitate mocking\n- Consider using a DI container for complex test setups\n\n## Test Organization\n\n- Group tests by feature or component\n- Use `[Trait(\"Category\", \"CategoryName\")]` for categorization\n- Use collection fixtures to group tests with shared dependencies\n- Consider output helpers (`ITestOutputHelper`) for test diagnostics\n- Skip tests conditionally with `Skip = \"reason\"` in fact/theory attributes\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-xunit"}},"content_hash":[156,166,24,200,218,240,184,234,219,22,15,201,170,113,247,179,72,104,196,39,102,238,24,67,237,125,81,238,16,48,76,225],"trust_level":"unsigned","yanked":false}
