samedi 19 janvier 2019

Spring Framework integration testing with overriding DAO class

Im setting up integration tests in Spring to test if my API endpoints are working correctly. There is no code because the question is a design problem question.

Right now i have a specific DAO class that talks to a real DB for IO operations.

I have a naive implementation of in-memory resource storage for testing that does not need any DB set up.

My question is how should I configure my tests in Spring so that the resource storing is done by the in-memory storage implementation. (I need to mock the http requests and assert that they work properly, right now a test is up and running but the resource storing is done on the real db using the DAO for that)

P.S. i can replace the real db in the application.properties to a H2 db which would work with the current DAO, but i dont need that change to be in the DB layer, i need it to be in the DAO layer, to use a different implementation of resource storage class.

I'm relatively new to Spring testing, and i'm using jUnit for testing.

Thank you very much. All help is appreciated.

Aucun commentaire:

Enregistrer un commentaire