We have inherited a large suite of code that has minimal testing. I'm looking to update and create tests.
We have a simple bean that has a private field that uses @value to inject a constant. This bean is constructed and passed around by numerous pieces of code which use the private @value. I want to set up a test suit to always inject some constant into the @value for any instantiated version of the bean.
I know how to inject a @value to a single bean, but considering how often the bean will be instantiated by spy in my test I don't want to have to inject mocks and inject @value into that mock for every case, I'd rather do this on a class level.
I'm aware that it's not good to abuse @value on private variables. We will hopefully fix this at some point, but at this point I don't want to mess with complicated number of constructors for an untestable behemoth of a class if I can avoid it. I'd like a way to test @value on a private field for now, and I'll look to moving how @value is utilized later once we have more stable/testable code base.
Can I configure this injection so it happens to all instantiated instances of the class automatically?