Let's say I have a user object... and there are a certain subsection of tests that always for example, want an "admin user" and others want "moderation users"

... or we want users with unicode names in a few tests. We can hold these in static classes, preconfigured if they are immutable or offer factories to generate them for use in our tests if needed... but is there a name for this kind of "cataloging" of fakes and mocks?

I'm mostly trying to read up on how people configure theirs: organization, maintenance, and other reading I can find on it.

  • In my experience, there's no such catalogs because it is not needed. Tests create required dependencies as needed. This may prevent issues such as changing an object in the catalog and breaking depending tests. If you find yourself needing the same objects over and over, you may benefit from creating a Builder for this class, which may have static methods creating common objects. This Builder would live only in the tests. – Vincent Savard Jan 11 at 13:06

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.