Open tt-es opened 1 year ago
did you end up fixing this? i am running into the exact same problem, on their own they succeed but in a batch only the first one succeeds, the hangfire service seems to try to access something that is taken down in the teardown. here is a link to my stackoverflow page:
@JenPullUp it's been a while but I think we just put all tests per test class in a single method. My guess is that NUnit runs the tests per class in a single process and hangfire has some persistent/static stuff that is not properly cleaned up or recreated. So you could also put each test in it's own class I guess.
I wrote a base class for integration tests of custom job filters. The class completely recreates the DI-Container and the HangfireJobClient and Server for every test. I currently have three tests for a cutom filter we use which all pass when run in isolation but as soon as I run them in one session (NUnit) only the first one passes. In subsequent test runs the job client won't return a job id when enqueueing.
Does hangfire keep some static settings in memory that has to be cleared for this to work?
the flow of the tests is as follow:
Register all relevant services (incl. hangfire) -> Create DI-Container -> Create JobClient & Server -> Run test method -> Dispose Server.