Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
查看 NDbUnit 框架。它正是为该测试设置而设计的 - 拥有一个由 XML 文件中的数据填充的数据库。
提示:
将其与内存数据库系统(例如 System.Data.SQLite 和您不再需要访问服务器计算机,从而使涉及数据库的测试(严格来说不是单元测试,而是集成测试)变得更加容易可靠且快如闪电。
呵呵!
托马斯
Look at the NDbUnit framework. It's designed for exactly that test setup - having a database filled by data from an XML file.
Tip:
Use it in combination with an in-memory database system such as System.Data.SQLite and you get rid of the necessity to hit a server machine, thus making your database-involving tests (which aren't - strictly speaking - unit tests, but integration tests) more reliable and lightning-fast.
HTH!
Thomas
如果您的测试命中数据库或 XML,那么它不是单元测试,而是集成测试。
如果您想要进行真正的单元测试,请谷歌搜索对象母亲模式。
如果您希望进行针对数据库的集成测试,您可以使用事务来确保数据库更改不会保留在测试范围之外。
我希望这有帮助。
If your test hits either a database or an XML it isn't a Unit Test it is an integration test.
If you are looking to do true unit tests google for the Object Mother pattern.
If you are looking to do integration tests that hit the database you can use Transactions to ensure that database changes are not persisted outside the scope of the test.
I hope this helps.