在进行单元测试时,在测试CRUD操作时是否必须使用数据库? sql lite可以解决这个问题吗?您是否必须以某种方式在内存中创建数据库?
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?
我正在使用mbunit.
I am using mbunit.
推荐答案否.集成实际的数据库将是集成测试.不是单元测试.
No. Integrating an actual DB would be integration testing. Not unit testing.
是的,如果您不能以任何其他方式抽象(模拟)DAL/DAO,则可以使用诸如 SQLite 或 MS SQL Compact 之类的任何内存数据库方式.
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.
有鉴于此,我必须指出,从DAL一直到单元测试都是可能的,但DAL本身不可能.在集成测试中,必须使用某种实际的数据库对DAL进行测试.
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.
更多推荐
在进行单元测试时,是否必须使用数据库来测试CRUD操作?
发布评论