1

I am writing unit tests for Extenject (Zenject) and using ZenjectUnitTestFixture but it looks like some of my singletons are not being recreated after test [Setup]. I have set breakpoints and checked that the Container registrations are being reset. However, one of the injected singletons has a dictionary in it that gets initialized at creation and it is only initialized on the first test. For subsequent tests it still has the contents from the previous test. Does anyone know why my singleton is still hanging around? I would have though it was a reference issue, like there was still a reference to my singleton so even when the container resets the instance stays around, but I would think that even in that case the reset container would inject the new singleton instance. Does anyone have any suggestions on where I could start looking? I can definitely add something to my singleton that lets me reset it at the start of every test, but I am concerned that the instance isn't getting recreated in case that is happening to other singletons in my test.

Ben
  • 115
  • 10

1 Answers1

0

This ended up not being an issue with Zenject. I had references to previous instances that were being reused. You want to make sure you don't reuse references to previous instances after setup runs. Previous instances won't be set to null. They will still be usable so you need to update all references to new calls of resolve after setup runs.

Ben
  • 115
  • 10