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 instanciated.

I have 200 tests where this default setting is fine.

However, I would like to now test the alternative.


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

Source: java

1 Comment

  1. Digin Dominic

    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.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.