在进行单元测试时,是否必须使用数据库来测试CRUD操作?

编程入门 行业动态 更新时间:2024-10-25 22:26:54
本文介绍了在进行单元测试时,是否必须使用数据库来测试CRUD操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在进行单元测试时,在测试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操作?

本文发布于:2023-10-24 08:31:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   操作   数据库   测试   CRUD

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!