Open Closed

Test Cases in Application #10362


0
smartlayer created

Hi,

I am creating test cases for my application.

A method in my service contains a hangfire job to send an email to the user, but when I am trying to use this method in one of my test case in Test project I get below error:-

Can you please let me know what is the issue

Thanks


1 Answer(s)
  • 0
    musa.demir created
    Support Team

    Hi @smartlayer

    You should disable background jobs in your test cases since background jobs work asynchronously.

    See: https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#disabling-job-execution

    https://github.com/aspnetzero/aspnet-zero-core/blob/fc16ab77828ed5aaebb34a5f923ad6628012fba9/aspnet-core/test/MyCompanyName.AbpZeroTemplate.Test.Base/AbpZeroTemplateTestBaseModule.cs#L44