You can also write your unit tests to not require any lookups at all:
@ContextConfiguration(locations = { "classpath:/path/to/test-config.xml" })@RunWith(SpringJUnit4ClassRunner.class)public class MyBeanTest { @Autowired private MyBean myBean; // the component under test @Test public void testMyBean() { ... }}
This gives an easy way to mix and match real config files with test config files.
For example, when using hibernate, I might have my sessionFactory bean in one config file (to be used in both the tests and the main app), and have by dataSource bean in another config file (one might use a DriverManagerDataSource to an in-memory db, the other might use a JNDI-lookup).
But, definitely take heed of @cletus's warning ;-)