Effective Test Case Writing and Design

Essentials of a Good Test Case

A well-written test case should:

  • Be easy to understand and execute
  • Have a specific objective
  • Contain clear requirements
  • Define clear pass/fail criteria
  • Be repeatable
  • Verify each action performed during the test case 

Best Practices for Creating Effective Test Cases

Good test cases are concise, targeted, and easy to execute and maintain. They make the testing process more effective by saving time and effort. Here are the top 10 best practices to follow when creating test cases:

  1. Plan and organize your testing before you begin

    • Create a folder structure organized by feature area

    • Plan out your tags for use in creating Orchestrations; for example, use tags such as 'Regression,' 'Smoke' and 'Integration'

  2. Keep regression test cases small and specific, this provides faster feedback since the tests take less time to execute and are clearer when defects occur in the application

  3. Functionize has a great feature that allows you to update similar steps across test cases, don't worry about over-engineering tests with reusable steps (Page Objects) until after you've created the test

  4. Avoid asserting large areas of the website; instead, verify each section individually - for example, instead of asserting the content of a 'div' that contains an entire menu, verify each menu item individually as this helps our ML engine better 'self-heal,' and it allows you to identify changes in the menu immediately when there is a change or defect

  5. Don't forget about instructions when using Architect, you have the option to add instructions in addition to the recorded actions in the test - this helps you plan, structure, and organize your test, for example, you can create an instruction called "Create Account" and then step through the account creation process - it is easy to convert the entire instruction into a reusable Page Object if you create them as you go

  6. Treat test steps as if you are writing them for a machine, keep the instructions very simple and single-purposed

    Good Examples:

    • Enter 'Hello World' into the Search Box
    • Click 'Search'
    • Verify that the text Search appears on the button next to the text 'Cancel'

    Bad Examples:

    • Click on the 4th chair in the search results
    • Click the yellow button (if it's not the only yellow button, or it's not very close to pure yellow)
    • Search Google and verify results for 'Puppy Picture'
  7. Design tests so that you can run them in parallel, as much as possible, this will yield faster results when you want to execute your entire regression suite

  8. Data-driven tests are extremely powerful. Consider where you can randomize data versus using known structured data.

  9. Orchestrations can help you manage integration testing across multiple projects, consider using API and Database tests for complete end-to-end integrated tests

  10. Don't forget about security testing - create folders or use tags for different types of security testing at the application level