Open Closed

Regarding Issue in Unit Test cases #1138


User avatar
0
ChetanKumbhar created

We have added following referance in one of microservice architecture to create user

Identity.HttpApi Identity.EntityFrameworkCore Identity.Application

you check details about that issue in https://support.abp.io/QA/Questions/1069/Not-able-to-create-user-in-MicroService-Architecture

but after that all unit test cases are failed for that service. We were facing issue of Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.AspNetCore.Mvc.AbpAspNetCoreMvcModule, Volo.Abp.AspNetCore.Mvc, Version=3.0.4.0, Culture=neutral, PublicKeyToken=null: Could not find singleton service: Microsoft.AspNetCore.Hosting.IWebHostEnvironment, Microsoft.AspNetCore.Hosting.Abstractions, Version=3.1.12.0, Culture=neutral, PublicKeyToken=adb9793829ddae60. See the inner exception for details. ---- System.InvalidOperationException : Could not find singleton service: Microsoft.AspNetCore.Hosting.IWebHostEnvironment, Microsoft.AspNetCore.Hosting.Abstractions, Version=3.1.12.0, Culture=neutral, PublicKeyToken=adb9793829ddae60

Then in following URL there are steps to resolve that issue

https://support.abp.io/QA/Questions/1077/Testing-Overridden-AppService#answer-1bbd38f2-5f8c-36ad-6eeb-39fb70a23930

I followed that steps:

Created WebEnvironmentHostMock.cs class implemented IWebHostEnvironment Interface.

step -1. public class WebHostEnvironmentMock : IWebHostEnvironment { public IFileProvider WebRootFileProvider { get; set; } public string WebRootPath { get; set; } public string EnvironmentName { get; set; } public string ApplicationName { get; set; } public string ContentRootPath { get; set; } public IFileProvider ContentRootFileProvider { get; set; }

    public WebHostEnvironmentMock()
    {
        var absoluteRootPath = "**********Path of Identity Server Microservice*****************" Drive:\\Folder\\Folder\\Folder\\Folder\\Folder\\***.***.IdentityServer;
        ContentRootPath = absoluteRootPath;
        WebRootPath = absoluteRootPath;
    }
}

step -2 : { [DependsOn( typeof(**********ApplicationModule), typeof(********DomainTestModule), typeof(AbpIdentityHttpApiModule), typeof(AbpIdentityEntityFrameworkCoreModule), typeof(AbpIdentityApplicationModule) )] public class **********TestModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddSingleton<IWebHostEnvironment>(new WebHostEnvironmentMock()); } } }

After This above issue get resolved, but there is following issue we are facing now.

'An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module SCV.Litmus.ProfileManagement.ProfileManagementTestBaseModule, SCV.Litmus.ProfileManagement.TestBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: SQLite Error 1: 'no such table: AbpUsers'.. See the inner exception for details.'

I checked douments, but couldn't find any solutions. Kindly help me out on this.

  • ABP Framework version: v3.0.4
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no / Yes
  • Exception message and stack trace: N.A
  • Steps to reproduce the issue: N.A

6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can refer the MyProjectNameEntityFrameworkCoreTestModule .

    https://github.com/abpframework/abp/blob/a5cf5364356c741a0b92c99e23ddeb367d374e50/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs#L18

  • User Avatar
    0
    ChetanKumbhar created

    Hi,

    As per your feedback, i refered MyProjectNameEntityFrameworkCoreTestModule. But still same issue we are facing.

    can we connect through online session? because this issue is on priority.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    Sure thing, please email me shiwei.liang@volosoft.com

  • User Avatar
    0
    ChetanKumbhar created

    Hi,

    After changes on call, I ran the Unit test cases, But now i am getting following exception.

    Autofac.Core.DependencyResolutionException HResult=0x80131500 Message=An exception was thrown while activating Volo.Abp.PermissionManagement.PermissionDataSeedContributor -> Volo.Abp.PermissionManagement.PermissionDataSeeder. Source=Autofac StackTrace: at Autofac.Core.Resolving.InstanceLookup.CreateInstance(IEnumerable1 parameters) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType) at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Volo.Abp.Data.DataSeeder.<SeedAsync>d__7.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at Castle.DynamicProxy.AsyncInterceptorBase.<ProceedAsynchronous>d__13.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.<ProceedAsync>d__7.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at Volo.Abp.Uow.UnitOfWorkInterceptor.<InterceptAsync>d__3.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__2.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at SCV.Litmus.ProfileManagement.ProfileManagementTestBaseModule.<>c__DisplayClass2_0.<<SeedTestData>b__0>d.MoveNext() in D:\Projects\core-platform-invoice-upload\SCV.Litmus\aspnet-core\modules\profile\test\SCV.Litmus.ProfileManagement.TestBase\ProfileManagementTestBaseModule.cs:line 35 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.<>c__DisplayClass15_0.<Run>b__0(Task t) at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func1 action) at Volo.Abp.Threading.AsyncHelper.RunSync(Func`1 action) at SCV.Litmus.ProfileManagement.ProfileManagementTestBaseModule.SeedTestData(ApplicationInitializationContext context) in D:\Projects\core-platform-invoice-upload\SCV.Litmus\aspnet-core\modules\profile\test\SCV.Litmus.ProfileManagement.TestBase\ProfileManagementTestBaseModule.cs:line 31 at SCV.Litmus.ProfileManagement.ProfileManagementTestBaseModule.OnApplicationInitialization(ApplicationInitializationContext context) in D:\Projects\core-platform-invoice-upload\SCV.Litmus\aspnet-core\modules\profile\test\SCV.Litmus.ProfileManagement.TestBase\ProfileManagementTestBaseModule.cs:line 26 at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module) at Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context)

    This exception was originally thrown at this call stack: [External Code]

    Inner Exception 1: DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Volo.Abp.PermissionManagement.PermissionDataSeeder' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.PermissionManagement.IPermissionGrantRepository permissionGrantRepository' of constructor 'Void .ctor(Volo.Abp.PermissionManagement.IPermissionGrantRepository, Volo.Abp.Guids.IGuidGenerator)'.

  • User Avatar
    0
    alper created
    Support Team Director

    https://support.abp.io/QA/Questions/1077/Testing-Overridden-AppService#answer-1bbd38f2-5f8c-36ad-6eeb-39fb70a23930

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

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