4 ms·
For service directory lookup, global variable is fine. For global scope queue, global variable is fine. For global scope logging service, global variable is f
by ww520 5y ago
For service directory lookup, global variable is fine. For global scope queue, global variable is fine. For global scope logging service, global variable is fine.
- sagichmal 5y agoEach of these things prevents isolated testing of dependent components. For that reason alone they are nonstarters.
- ori_b 5y agoglobalvar = new NopImpl() works fine for testing. If you squint, you can even think of dependency injection frameworks like Dagger as a lot of boilerplate around a global database of instantiations.
- deleted 5y ago[deleted]
- dcow 5y agoUntil you try to run two tests at once, one which requires NopImpl and one which requires the real impl.
- sagichmal 5y agoAs dcow pointed out, it really doesn't work fine for testing, as it couples what should be isolated tests together, and prevents them from being executed concurrently.