Breaking

Monday, April 19, 2021

XUnit–Dependency Injection

To use the standard IoC container inside your Xunit tests, I would recommend to use a separate fixture. Inside this fixture you can add all dependencies to the ServiceCollection and build the ServiceProvider:

Now you can use the IoC container inside your tests by injecting the fixture inside the constructor:

No comments:

Post a Comment