Search code examples
javaspringjunitapplicationcontextspringjunit4classrunner

Junit test; Is it possible to configure a Bean's default property, before application context starts up?


I have a Bean with a property "DBServer"; It has a default of "location1";

During application startup, Depending on the value of "DBServer", different classes are instantiated.

I have 200 tests where this default setting is fine.

However, As of now,I would like to test the alternative.

Question:

Is there a way to from within a junit test case to reset the default before the application context starts ?


Solution

  • Junit won't start application context unless you write setUp method under @before annotation. In that case you can initialize your bean with any values.