I use Guice to instantiate a VocabularyAPI
object for one of my unit tests unitTest1()
. However, for another test (unitTest2()
), I simply use mockito's @Mock
annotation to mock an instance of the same class - VocabularyAPI
.
I noticed that when I only run unitTest2()
- mockito's mock setting for my VocabularyAPI
is configured correctly. However, when I run the entire test suite (both unitTest1()
and unitTest2()
), both the tests are instantiated with the settings from the injector.
How can I limit the scope of the injected object to only inside the test that it is being injected? I want to be able to use the injected object in unitTest1()
and mocked object for unitTest2()
.
Any problems in using local variables?
In
unitTest1()
:In
unitTest2()
: