xunit

xUnit

Used in 130 csharp projects (avg ★355)

C#
Testing
Default
Used by 130 projects

Details

Language / Topic
csharpC#
Category
Testing

Rules

balanced

xUnit

- Use `[Fact]` for single test cases and `[Theory]` with `[InlineData]` for parameterized tests. Use `Assert.Equal()`, `Assert.Throws<T>()`, and `Assert.Contains()`. One assertion focus per test method.

xUnit

- Use `[Fact]` for single test cases and `[Theory]` with `[InlineData]` for parameterized tests. Use `Assert.Equal()`, `Assert.Throws<T>()`, and `Assert.Contains()`. One assertion focus per test method.
- Use `[ClassFixture<T>]` for shared expensive setup across tests in a class. Use `[CollectionFixture<T>]` for sharing across multiple test classes. Use `IAsyncLifetime` for async setup/teardown instead of constructor/Dispose. Mock dependencies with Moq or NSubstitute: `Mock<IService>().Setup(x => x.Method()).Returns(value)`.