Skip to content

Instantly share code, notes, and snippets.

View vancodocton's full-sized avatar

Nguyễn Kỳ Dương Trường vancodocton

View GitHub Profile
@bradwilson
bradwilson / Test Collections.md
Last active October 8, 2022 04:12
Using test collections in xUnit.net v2

Test collections are the test grouping mechanism in xUnit.net v2. They serve two purposes:

  1. They delineate the "parallelism" boundary; that is, tests in the same collection will not be run in parallel against each other;
  2. They offer collection-wide fixtures through the use of ICollectionFixture<TFixtureType>.

The simplest way to use test collections is simply by name. Put two classes into the same named collection, and they can derive benefit #1 above:

[Collection("MyCollection")]
public class TestClass1