Override Interface for tests #235
Unanswered
joelsantos
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hello. Thanks for trying it out ! In my opinion, for each unit test, you can initialize the object manually. (No need for DI magic). As for how to override the LifetimeScope of an existing scene, the following may be of use. using (LifetimeScope.Enqueue(overrideBuilder => overrideBuilder.RegisterInstance(gameContainer)))
{
await SceneManager.LoadSceneAsync("TestTarget");
// or Instantiate LifetimeScope of a test target...
} I hope this helps in some way! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there. First of all, great project that you have here 👍 I'm in the process of migrating my game from Zenject to it, and I'm having a few issue.
I'm trying to override an interface that is originally registered on the RootLifeScope with a Mock/Substitute, however it's not being picked up correctly. The test has to load a scene, before running.
Right now I have, but this doesn't seem to work.
Also, it would be great to have a few examples for UnityTests.
Thanks in advance,
Joel Santos
Beta Was this translation helpful? Give feedback.
All reactions