.NET是否有用于填充测试数据的框架? [英] Is there any framework for .NET to populate test data?
本文介绍了.NET是否有用于填充测试数据的框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用c#,对于单元测试和集成测试,通常需要根据属性自动填充字段.
可以说我们将测试是否可以写入用户数据并将其返回数据库.
I am use c# and for unit testing and integration testing usually I need to populate fields automatically based on attributes.
Lets say we will test if we can write and get back user data to database.
- 我创建一个用户对象,填充字段,将用户写入数据库
- 从数据库读取用户对象
- 检查字段,如果我写的东西和我读的东西一样
有没有自动向用户填充测试数据并检查两个对象是否具有相同值的框架?
Is there any framework to populate user with test data automatically and check if two object are have the same values?
示例代码可能会这样
User user = new User();
AutoPopulator.Populate(user);
user.Save();
推荐答案
看看 NBuilder .它使您可以使用随机数据,递增值以及您可能想到的任何内容来构建测试对象.全部通过一个流畅的界面.
Take a look at NBuilder. It lets you build test objects with random data, incrementing values, and anything you can probably think of. All through a nice fluent interface.
这篇关于.NET是否有用于填充测试数据的框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文