Fixtures best practices: need feedback

I need to work with fixtures and MiniTest on a Rails project and I have
some questions on best practices with using fixtures. Please bear with
me :slight_smile:

  • Should I restrict fixtures attributes only to those required in my
    current tests? Say, if I have no tests involving the user’s role I
    simply don’t mention the role association in the fixtures. Model
    scaffolds generally add all attributes to the fixtures…

  • A friend of mine told me he wants to dump anonymized portion of a
    production database to fixtures… What’s your take on this?

  • What’s your opinion on having fixtures’ names representing their use
    cases rather than being very generic?

test/fixtures/users.yml

owner_on_junior_account_with_posts_limit:
role: owner
account_type: junior
posts_limit: 1000

VS

user35:
role: role1
account_type: account4
posts_limit: 1000

  • Is it worth to be trying to reuse fixtures as much as possible? My
    considerations here are development cost and test suite performance.

  • Is it worth mocking/stubbing existing fixtures (e.g. use Mocha’s
    :any_instance) to get to a specific edge case, or it’s cleaner to just
    create a new fixture set.

Finally, I’d love to find an open source project that uses fixtures and
learn best practices from there.

Any feedback is very much appreciated. Thank you guys!