0
SamirBoutazzout created
Hello everyone,
I would like to get some information regarding mocking the CurrentUser instance for tests. I have tried this implementation that I found on google:
protected override void AfterAddApplication(IServiceCollection services) { currentUser = Substitute.For<ICurrentUser>(); services.AddSingleton(currentUser); }
I put this in my test class and when I debug it seems to work, but when the executing code reaches the CurrentUser instance in my application service, it throws null exception as shown below.!
- ABP Framework version: v6.0.2 Commercial
- UI Type: Angular
- Database System: EF Core (PostgreSQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace: System.NullReferenceException: 'Object reference not set to an instance of an object.'
- Steps to reproduce the issue:
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
3 Answer(s)
-
0
Hi ,
Can you share error logs .
Thanks,
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Do you mean the stacktrace of the exception? Nothing is logged in the log file when the test throws the exception.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Yes, please send a stack trace if any
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)