I have two beans of the same name and same class. I want to mock (mocking is not done through @Mock annotation but done in the Spring file because of some reason) one of them and leave the other one as normal (used for integration tests).
One way, I could think of is to change resource file in @ContextConfiguration's location attribute and load separate configs for unit testing and integration testing.
Is there any other way to accomplish this task?
I understand that there are some issues like Why not to use @Mock?, Why to have two beans of same class and same bean? but I cannot change that because some part is already there and I don’t want to change that.
Thanks,
I have separate configuration files when necessary for different purposes. One scenario is one for testing and another for production. I agree with your first thought.