I think you are mixing up two different concepts here.
First, the purpose of the data that you create with Faker
(in your case, database seeding) is to simulate real life scenarios in your application. For example, if you are developing a blogging platform, you can use it to have some blog posts with tags, user comments and author comments.
When it comes to testing, you can use this in your functional or acceptance tests. For example, if you want to test something like test tag page shows posts tagged with X tag
or test user can only delete his own comments
, then you could take advantage of Faker
data to have some previous posts, tags and comments to work with.
On the other hand, FactoryMuff
allows you to quickly create an instance of any given model. Consider the scenario when you are unit testing the validation method for your Post
model, so you would have to:
// 1. create new Post
// 2. fill it with data
// 3. try to validate
Having your database seeded is not going to be useful here, since you are going to be creating a new model, and FactoryMuff
will do steps 1 and 2 for you. Also, keep in mind that when you are unit testing, you want to do it in isolation, so you shouldn't need to touch your database at all. Instead, you could mock your database object and return fake models and its possible relationships (FactoryMuff
to the rescue again).
Finally, I think that maybe you are not seeing the advantages of FactoryMuff
functionality because your application may be still small, but you will and won't mind writing a few static methods as your codebase –and your tests– grows.