Testing by Gregory

Add Category to Test

Adding a category to a test for filtering purposes. The source code sample demonstrates how to use the Trait attribute in C# with xUnit to categorize a test as an "IntegrationTest." This categorization helps in filtering and organizing tests based on their nature or purpose.

By using the Trait attribute with key-value pairs like "Category" and "IntegrationTests," tests can be grouped and executed selectively during testing workflows.

Sample code snippet:

[Fact, Trait("Category", "IntegrationTests")]
public async Task AcquireToken_GetToken_TokenNotNullOrEmpty()
{
   // test implementation
}

Comments