Tests should resemble users

The more your tests resemble the way your software is used, the more confidence they can give you. Automated tests are by nature more abstract than your users, but using tools that enable you to simulate users as closely as possible will result in more confidence in shipping good experiences and help you avoid test babysitting that results from implementation details-based tests.

Examples

  • You're testing a sign-up form that includes name, email, and password fields. Instead of testing the internal function that formats the form data, you write a test that fills in the form fields with realistic values (e.g., name: 'Jane Doe', email: 'jane@example.com') and submits it. Then, you assert that the resulting screen shows a welcome message or an error message if something went wrong, just as a user would experience it.
  • While testing a 'Submit Feedback' button, rather than triggering a click handler directly, you simulate a full user journey: enter feedback text, click the submit button, and check for confirmation. This approach ensures you test all dependencies in context (button, form, submit handler), resembling the way a user interacts with the system.