The basics of xUnit
xUnit provides the hosting environment for your tests. One important feature of xUnit is that it is AAA-convention friendly. It also integrates with the VS IDE and its Test Explorer.
Extensive examples using xUnit appear naturally in this book. However, it is worth dedicating a few sections to discussing the principal features of this framework.
Fact and theory attributes
In your test project, any method that is decorated with Fact
or Theory
will become a test method. Fact
is meant for a non-parametrized unit test, and Theory
is for a parametrized one. With Theory
, you can add other attributes, such as InlineData
, for parametrization.
Note
VS will give you a visual indication above the method name that you can run the methods decorated with these attributes, but sometimes it doesn’t until you run all the tests.
Running the tests
Each unit test will run independently and instantiate the class. The unit tests do not share each other’...