Ends in:
7 DAYS
20 HRS
15 MIN
47 SEC
Ends in:
7 D
20 H
15 M
47 S
Open Closed

Issue with Test Project when creating solution with CLI #6639


User avatar
0
alex@livemobility.com created
  • 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() BookStoreTestBase1.ctor() BookStoreApplicationTestBase1.ctor() SampleAppServiceTests1.ctor() line 19 Test.ctor() RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions) ----- Inner Stack Trace ----- ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) &lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context) ResolvePipeline.Invoke(ResolveRequestContext context) RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.b__1(ResolveRequestContext context) SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) &lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context) &lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context) CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.b__1(ResolveRequestContext context) KeyedServiceMiddleware.Execute(ResolveRequestContext context, Action1 next) &lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;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, IEnumerable1 parameters, Object& instance) ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable1 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, Func3 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(Func1 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, Action1 next) <>c__DisplayClass14_0.b__1(ResolveRequestContext context) DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) &lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context) &lt;&gt;c__DisplayClass41_0.&lt;PropertiesAutowired&gt;b__0(ResolveRequestContext context, Action1 next) DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) &lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context) &lt;&gt;c__DisplayClass39_0.&lt;OnActivated&gt;b__0(ResolveRequestContext context, Action1 next) CoreEventMiddleware.Execute(ResolveRequestContext context, Action1 next) &lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context) &lt;&gt;c__DisplayClass8_03.b__1(ResolveRequestContext ctx, Action1 next) DelegateMiddleware.Execute(ResolveRequestContext context, Action1 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)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    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.

  • User Avatar
    0
    alex@livemobility.com created

    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.

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    Have you added Volo.Abp.Identity; in SampleAppServiceTests.cs file. Please check once.

    Thank you.

  • User Avatar
    0
    alex@livemobility.com created

    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?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you share the full steps to reproduce the problem? I will check it. thanks.

  • User Avatar
    0
    alex@livemobility.com created

    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 :)

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Please move TestAppService to the EntityFrameworkCore.Tests project.

    The Application.Testsproject is used to write application service test base classes

  • User Avatar
    0
    alex@livemobility.com created

    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?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I think there is nothing wrong with the documentation

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    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

  • User Avatar
    0
    alex@livemobility.com created

    Hi,

    I waas trying to say that this documentation is not up to date: https://docs.abp.io/en/abp/latest/Testing

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi alex

    I will update the documentation.

  • User Avatar
    0
    alex@livemobility.com created

    Hi

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi alex

    Please create a new question, Thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06