Any tips or best practices for writing tests involving data? My app has a search bar that searches the database for matching text. For example:
Search 'Joe', will return all people with firstname = 'Joe', lastname = 'Joe', or has 'Joe' in their email address.
I can think of 2 potential ways to test this:
1) Search for 'Joe', and check the data returned. Every row returned should have 'Joe' in firstname, lastname or email. Issue with this is if a row should be returned, but isn't, the test won't pick this up.
2) Load test data, run search and check results. In this case, I know exactly how many rows should be returned. This effectively means I need to load test data before running each test (and delete it after...in case my code is broken and it writes bad data, it wont screw me up next time i run test).
Any thoughts? Is there a 3rd option?
Aucun commentaire:
Enregistrer un commentaire