July 2024
Intermediate to advanced
360 pages
9h 45m
English
This appendix contains some other xUnit features that may be useful. You can find the full documentation for xUnit at https://xunit.net/#documentation.
Traits allow you to assign any number of properties to a test. You can use traits to organize tests into categories to exercise specific areas of your code. Traits are applied via attributes and can be set on the method, class, or assembly level. You could mark the ComicFinderTests class as an integration test and the ComicRepositoryTests class as a unit test, for example, as shown in the following listing.
Listing F.1 Distinguishing unit and integration tests with traits
[Trait("Category", "Integration")]
public class ComicFinderTests : IDisposable
{
Read now
Unlock full access