Search This Blog

2021-03-03

Use of XUnit in .NET Core application - Part 02: Grouping, Class Fixture, Parallel Execution

 Group by Trait attributes

Class Fixtures and IClassFixtures

To avoid creation of class in every test method, create it in construction of test class using dependency injection.













Collection

Use same class for example, customer class in multiple test classes like customerTest and CustomerDetailedTest classes.

























Create a new Class CustomerFixture






Modify CustomerTestsClass and inject customerfixture









Modify CustomerDetailsTest










Create a new class for for CustomerFixtureCollection to create a mapping of the testclasses using the collection Customer






Use the customerfixture classes in the existing test method







Parallel Execution



Then how does xunit know that the above class should be used as renderer?

Add assemblyinfo.cs(if don’t exist) and add an entry










Note the Namespace,classname and assemblyname in the TestCollectionOrderer

No comments: