When unit testing, do you have to use a database to test CRUD operations?

后端 未结 7 1009
广开言路
广开言路 2021-02-09 21:11

When unit testing, is it a must to use a database when testing CRUD operations? Can sql lite help with this? Do you have to cre-create the db somehow in memory?

I am usi

相关标签:
7条回答
  • 2021-02-09 21:45

    No. Integrating an actual DB would be integration testing. Not unit testing.

    Yes you could use any in-memory DB like SQLite or MS SQL Compact for this if you can't abstract (mock) your DAL/DAO in any other way.

    With this in mind I have to point out, that unit testing is possible all the way to DAL, but not DAL itself. DAL will have to be tested with some sort of an actual DB in integration testing.

    0 讨论(0)
提交回复
热议问题