i have a class with the field that initialized without setter using static call:
class A{
private B b = Env.getEnv().getInstance(“b”);
…
}
i want to test class A supplying a mock of class B.
Is it possible?
The A class is not mine and i can’t use setter, reflection here also not possible.
Any help will be appreceated!
Thank you,
Yan
It depends what
Env.getEnv(...).getInstance()does. Can you change that to return your mock? If not, you’ve basically got a class which really isn’t designed for testability, and you’ll find it hard to inject the dependencies.