- ABP Framework version: v8
- UI Type: Angular /
- Database System: EF Core (SQL Server,)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
- Exception message and full stack trace:
- Steps to reproduce the issue:
Hello ABP team
recently we have created two new solutions ( commercial and community ) and both templates have the same issue. We are trying to test an application service. When we want to use the sample appservice test, SampleAppServiceTests with the module generated for the test project, we get the following exception:
Acme.BookStore.Test.Initial_Data_Should_Contain_Admin_User Source: SampleAppServiceTests.cs line 25 Duration: 1 ms
Message: Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Acme.BookStore.BookStoreTestBaseModule, Acme.BookStore.TestBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating Volo.Abp.Identity.IdentityDataSeedContributor -> Volo.Abp.Identity.IdentityDataSeeder.. See the inner exception for details. ---- Autofac.Core.DependencyResolutionException : An exception was thrown while activating Volo.Abp.Identity.IdentityDataSeedContributor -> Volo.Abp.Identity.IdentityDataSeeder. -------- Autofac.Core.DependencyResolutionException : None of the constructors found on type 'Volo.Abp.Identity.IdentityDataSeeder' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.Identity.IIdentityRoleRepository roleRepository' of constructor 'Void .ctor(Volo.Abp.Guids.IGuidGenerator, Volo.Abp.Identity.IIdentityRoleRepository, Volo.Abp.Identity.IIdentityUserRepository, Microsoft.AspNetCore.Identity.ILookupNormalizer, Volo.Abp.Identity.IdentityUserManager, Volo.Abp.Identity.IdentityRoleManager, Volo.Abp.MultiTenancy.ICurrentTenant, Microsoft.Extensions.Options.IOptions`1[Microsoft.AspNetCore.Identity.IdentityOptions])'.
See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
Stack Trace:
ModuleManager.InitializeModules(ApplicationInitializationContext context)
AbpApplicationBase.InitializeModules()
AbpApplicationWithExternalServiceProvider.Initialize(IServiceProvider serviceProvider)
AbpIntegratedTest1.ctor() BookStoreTestBase
1.ctor()
BookStoreApplicationTestBase1.ctor() SampleAppServiceTests
1.ctor() line 19
Test.ctor()
RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
----- Inner Stack Trace -----
ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context) ResolvePipeline.Invoke(ResolveRequestContext context) RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action
1 next)
<>c__DisplayClass14_0.b__1(ResolveRequestContext context)
SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context) CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action
1 next)
<>c__DisplayClass14_0.b__1(ResolveRequestContext context)
KeyedServiceMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context) ResolvePipeline.Invoke(ResolveRequestContext context) ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest& request) ResolveOperation.ExecuteOperation(ResolveRequest& request) ResolveOperation.Execute(ResolveRequest& request) LifetimeScope.ResolveComponent(ResolveRequest& request) IComponentContext.ResolveComponent(ResolveRequest& request) ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable
1 parameters, Object& instance)
ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable
1 parameters)
ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
AutofacServiceProvider.GetRequiredService(Type serviceType)
ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
DataSeeder.SeedAsync(DataSeedContext context)
AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapter.ProceedAsync()
UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed)
<b__0>d.MoveNext() line 41
--- End of stack trace from previous location ---
TaskExtensions.WaitAndUnwrapException(Task task)
<>c__DisplayClass15_0.b__0(Task t)
ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
TaskExtensions.WaitAndUnwrapException(Task task)
AsyncContext.Run(Func1 action) AsyncHelper.RunSync(Func
1 action)
BookStoreTestBaseModule.SeedTestData(ApplicationInitializationContext context) line 37
BookStoreTestBaseModule.OnApplicationInitialization(ApplicationInitializationContext context) line 32
OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module)
ModuleManager.InitializeModules(ApplicationInitializationContext context)
----- Inner Stack Trace -----
<>c__DisplayClass14_0.b__0(ResolveRequestContext context, Action1 next) DelegateMiddleware.Execute(ResolveRequestContext context, Action
1 next)
<>c__DisplayClass14_0.b__1(ResolveRequestContext context)
DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context) <>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext context, Action
1 next)
DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context) <>c__DisplayClass39_0.<OnActivated>b__0(ResolveRequestContext context, Action
1 next)
CoreEventMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context) <>c__DisplayClass8_0
3.b__1(ResolveRequestContext ctx, Action1 next) DelegateMiddleware.Execute(ResolveRequestContext context, Action
1 next)
<>c__DisplayClass14_0.b__1(ResolveRequestContext context)
ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
Can you help us out here? I suppose some module is missing, but I wasn't able to pinpoint it yet
Thanks Alex
14 Answer(s)
-
0
Hello ,
Could you please check this if it helps you https://docs.abp.io/en/commercial/latest/tutorials/book-store/part-4?UI=NG&DB=EF
Thank you.
-
0
Hi Anjali,
Yes, the generated test project for integration tests is working correctly. I have an issue with the one generated for application layer testing.
-
0
Hello ,
Have you added
Volo.Abp.Identity;
inSampleAppServiceTests.cs
file. Please check once.Thank you.
-
0
Hi Anjali,
Yes, I tried also what you suggested. I think that something changed in the test infrastructure, and now somehow we need to use the EF core test project?
Can you check internally who the test projects are meant to be used with the latest version?
-
0
Hi,
Could you share the full steps to reproduce the problem? I will check it. thanks.
-
0
Hi,
Try to run TestAppServiceTests~Initial_Data_Should_Contain_Admin_User
you will see exception: Message: Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Acme.BookStore.BookStoreTestBaseModule, Acme.BookStore.TestBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating Volo.Abp.Identity.IdentityDataSeedContributor -> Volo.Abp.Identity.IdentityDataSeeder.. See the inner exception for details. ---- Autofac.Core.DependencyResolutionException : An exception was thrown while activating Volo.Abp.Identity.IdentityDataSeedContributor -> Volo.Abp.Identity.IdentityDataSeeder. -------- Autofac.Core.DependencyResolutionException : None of the constructors found on type 'Volo.Abp.Identity.IdentityDataSeeder' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.Identity.IIdentityRoleRepository roleRepository' of constructor 'Void .ctor(Volo.Abp.Guids.IGuidGenerator, Volo.Abp.Identity.IIdentityRoleRepository, Volo.Abp.Identity.IIdentityUserRepository, Microsoft.AspNetCore.Identity.ILookupNormalizer, Volo.Abp.Identity.IdentityUserManager, Volo.Abp.Identity.IdentityRoleManager, Volo.Abp.MultiTenancy.ICurrentTenant, Microsoft.Extensions.Options.IOptions`1[Microsoft.AspNetCore.Identity.IdentityOptions])'.
The issue is that now we have to implement the appservice tests as abstract, creata a new class in Acme.BookStore.EntityFrameworkCore.Tests and run tests from there
If this is the new approach, it's fine but an explanation and updated documentation would be fine :)
-
0
-
0
Hi,
thanks for the input. Your statement contradicts a bit what we have here: https://docs.abp.io/en/abp/latest/Tutorials/Part-4?UI=NG&DB=EF#testing-the-bookappservice
Also, this documentation is not up to date: https://docs.abp.io/en/abp/latest/Testing
Is it possible to get some explanation about why there was a change in approach?
-
0
-
0
Is it possible to get some explanation about why there was a change in approach?
Yes, You can check the discussion here: https://github.com/abpframework/abp/issues/17488
-
0
Hi,
I waas trying to say that this documentation is not up to date: https://docs.abp.io/en/abp/latest/Testing
-
0
hi alex
I will update the documentation.
-
0
-
0
hi alex
Please create a new question, Thanks