Updated 15/09/2023
xUnit.net is a free, open source, community-focused unit testing tool for the .NET Framework. Install xunit
from Nuget as version 2.4.1
.
Fact
See Testing Strategies to understand what U_I_E
is.
1 | [ ] |
Other asserts
1 | Assert.Contains(collection, x => x.SweetProp == "Foo"); |
Theory - Inline Data
1 | [ ] |
Theory - Member Data
1 | public static IEnumerable<object[]> FooTestData() |
Shared Context between Tests
xUnit doesnt have explicit [SetUp]
and [TearDown]
annotations like NUnit, instead they say you must use a Constructor and Dispose.
1 | public class StackTests : IDisposable |
Exceptions
Verifies that the exact exception is thrown (and not a derived exception type). Returns the exception that was thrown, when successful.
1 | // Act |
Naming rules
Define conventions across project from this post
1 | [ ] |
Architecture tests
- Enforce command handler naming
1 | [ ] |
- Enforce microservice architecture (copied from Milan Jovanović)
1 | [ ] |