Customize FixtureMappingManager / fixture instantiation without overriding the full test pipeline #3567
|
Hello ! In this integration test framework, i enabled the possibility to use dependency injection. My fixture is what i called an environment, and an environment is a collection of infrastructure. Environment needed dependencies too, so for know i've been using the ServiceProvider as a service locator directly in the environment. I found that XUnit.DependencyInjection does that, but not really how i want. Here is my goal: // FixtureMappingManager.cs L170
// Create the object
try
{
// result = ctor.Invoke(ctorArgs); -- not anymore
result = ActivatorUtilities.CreateInstance(serviceProvider, fixtureType, ctorArgs);
// Service provider would be provided by finding the nearest DI configurator from the test class.
fixtureCache[fixtureType] = result;
}
catch (Exception ex)
{
throw new TestPipelineException(string.Format(CultureInfo.CurrentCulture, "{0} fixture type '{1}' threw in its constructor", fixtureCategory, fixtureType.SafeName()), ex.Unwrap());
}Is there any known way to customize this without overriding the whole test pipelines ? I hope i didn't missed something on the doc/code that could answer that question. |
Replies: 1 comment 5 replies
|
We have The earliest possible place to set this would be a test pipeline startup object (implement |
Available in v3
4.0.0-pre.104https://xunit.net/docs/using-ci-builds