Closed RavindraBarapatre closed 7 years ago
You need to register an instance of ITestOutputHelper
as described in the README.md
.
builder.Register(context => new TestOutputHelper())
.As<ITestOutputHelper>()
.InstancePerLifetimeScope();
I followed all the steps as given in documentation. still I am getting same error.
That is odd. Can you provide a sample that reproduces the issue?
Closing. I'll reopen if sample/repo of the issue appears.
@dennisroche See http://stackoverflow.com/questions/43450788/xunit-test-with-autofac for a description in greater detail. Actually you have to register the TestOutputHelper
also AsSelf()
since the AutofacTestInvoker
resolves an instance of this class.
So the correct way of initializing the Autofac-Infrastructure to get the library running could be
builder.Register(context => new TestOutputHelper())
.AsSelf()
.As<ITestOutputHelper>()
.InstancePerLifetimeScope();
You should consider adopting the README.md, I ran into the same problem today.
@peterwurzinger thanks. would you mind putting up a PR to update the README.md
?
Sure, PR is up.
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable
1 parameters) at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable
1 parameters) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Result2 Message: Autofac.Core.Registration.ComponentNotRegisteredException : The requested service 'Xunit.Sdk.TestOutputHelper' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.