I have a test class with a constructor that needs an IService.
public class ConsumerTests
{
private readonly IService
Yes it's possible with Xunit.DependencyInjection
Install-Package Xunit.DependencyInjection
and you can inject your services
[assembly: TestFramework("Your.Test.Project.Startup", "AssemblyName")]
namespace Your.Test.Project
{
public class Startup : DependencyInjectionTestFramework
{
public Startup(IMessageSink messageSink) : base(messageSink) { }
protected override void ConfigureServices(IServiceCollection services)
{
services.AddTransient();
}
}
}
https://github.com/pengweiqhca/Xunit.DependencyInjection