测试 开发环境生成测试数据 faker

helapu · February 01, 2017 · Last by realwol replied at February 04, 2017 · 6552 hits

在开发环境生成大量的数据,但是这些数据要看上去比较的真实 推荐一个 gem faker

https://github.com/stympy/faker

简单使用如下

Faker::Name.name      #=> "Christophe Bartell"
Faker::Internet.email #=> "[email protected]"

但是这些数据不保证唯一性,如果需要唯一性的数据的话,使用如下代码

Faker::Name. unique.name      #=> "Christophe Bartell"
Faker::Internet. unique.email #=> "[email protected]"

faker 大坑,用了之后测试奇慢

You need to Sign in before reply, if you don't have an account, please Sign up first.