I use NUnit integration tests. I am trying to test to make sure that user can't create account with existing email. ([email protected])
I need to have test data in the database (account with [email protected] email).
I can create this account in the test function, or in the sql script (and run it before integration tests).
Where is the better place to create this test data?
Neither option is wrong but there are a number of ways to extend and solidify your strategy:
None of these solutions are mutually exclusive. I would recommend the last item especially (pluggable provider) and then a choice between object mocking or faux but quality db test data.
Your best bet is to look into Dependency Injection and Mocking frameworks. This way you can swap out data providers with mocked data providers and use the data that fits your needs for the specific test.
If you're using NHibernate or similar, you can always recreate your db schema before each test(fixture).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With