1

When writing a test plan to check that a page displays certain things, should I write separate tests for each item, or one test total? For example, User Acceptance Criteria states "The page should display name, address, and phone number." Which of the following is better?

  1. Go to page
  2. Confirm name, address, and phone number are present

or

  1. Go to page
  2. Confirm name is present
  1. Go to page
  2. Confirm address is present
  1. Go to page
  2. Confirm phone number is present

I'm testing manually for now with the intention of implementing automated testing eventually.

2 Answers 2

0

It's a good question although the answer is "it depends" until you define "better"

The first way (1 test checks all assertions) is better for:

  • more compact code
  • quicker tests, only 1 setup needed
  • easier to maintain tests
  • quicker development

The second way (1 test for each assertion) is better for:

  • encouraging more specific and descriptive test and error reporting
  • making each test specific to just one thing
  • smaller tests that are easier to distribute and run in parallel
  • teams with more resources to maintain all the extra boiler-plate code

You'll often hear the "1 assertion per test" rule or guideline but I have found that in some cases, such as ui tests, if you want to go to a page and then verify that 15 pieces of information show correctly based on a given set of conditions, having 15 test cases with setup and tear-down for each one is too much to maintain and too slow to run frequently

0

You also may consider that the complex the test the more defects will be associated with it. My rule of thumb, and again context is important, is that a test should uncover one bug. The additional reason for thinking along these lines is that if you are going to automate your tests you want to be able to pinpoint quickly what the specific reason for the failure is, otherwise your troubleshooting of automation failures can be more time-consuming than necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.