Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
factorygirl 在测试环境中的目的是设置测试中使用的对象吗?
简而言之,是的。
虽然它做得更多。它允许您创建模型对象及其依赖项,它使您可以选择是否将这些对象持久保存到您的数据库中,以及创建存根对象。
此外,它使您在测试中使用的模型对象更加明显。Fixtures 倾向于隐藏这些信息,你别无选择,只能持久化这些对象。