Search code examples
javaspringtestingdatasourcespring-test

Make a fake javax.sql.DataSource?


I have to write tests with String Test framework where many DB connections was used.

In test I don't need all data sources but Spring want them all to inject.

Are there any standard or well known fake javax.sql.DataSource implementation just to satisfy Spring DI mechanic?


Solution

  • You can use Mockito framework. Using Springockito you can mock your datasources on a Spring environment.

    Credit of this resource is for kubek2k in this SO answer.