Skip to main content
Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.

Build Your Test Case

Learning Objectives

After completing this unit, you’ll be able to:

  • Outline common features of a test case.
  • Explain how to add to a test case.
  • Explain how to maintain a test case.

Write a Test Case

Once you plan your test case, it’s time to write it. A well-written test case outlines the sequence of steps needed to test a specific feature or functionality. There are various structures teams may choose to use (such as Gherkin Syntax from Testing Methodologies), but most share common components to provide clarity and consistency.

  • Preconditions: Specify what needs to be true before executing the test. For example, if you’re testing the functionality to create a new contact, the preconditions might include that the user is already logged in, signaling that the login functionality is not to be tested.
  • Steps: Write clear, simple steps broken down into individual actions. Avoid compound steps that can confuse the execution and the results. The goal is for anyone on your team to easily execute the test case without ambiguity.
  • Results: Identify the expected results before you test. Refer to whether you’re testing the happy or negative path and be clear about what you do and don't expect to happen.

In addition to these core components, there are a few other helpful elements. Write a simple test case title that reflects the objective of the test case for easy identification and organization. Add a status, too, to indicate whether it’s in a design or review phase versus one that’s been approved and is ready for execution.

Adding to a Test Case

Before adding to your test cases, think about incorporating modularity into your test cases. A modular approach to test case development means your test cases are broken down into smaller units called modules.

Once written, these modules can be reused in other test cases, reducing the time it takes to both write and maintain your test cases. As your test cases grow, reusability becomes an essential to the efficiency of your test case management.

Check out the video below to see one scenario where modular, reusable components save time and effort.

Another important practice when adding on to test cases is parameterization. As you see in Testing Methodologies, instead of hard-coding specific values, parameterization uses dynamic variables. Otherwise, your test case depends on fixed values to pass.

Maintaining a Test Case

Applications are ever-evolving, so test cases need regular reviews and updates. Take a proactive approach by creating a system for accomplishing this. It’s better to discover your test cases are outdated before you spend time executing and debugging them.

Start with a system for documentation for your team. A standardized folder structure and naming conventions for your test cases ease collaboration and promote transparency. Also decide where to keep your test cases, whether that’s localized or via a third-party tool. Finally, create a system for documenting and sharing changes you make during your systematic reviews.

As you put your plan in place, make sure you’re maintaining your data, too. Anywhere you don’t parameterize your test cases risks false positives or negatives during testing if these aren’t updated as needed.

Sum It Up

Test cases are the foundation of your testing. Plan them carefully in alignment with your business requirements. As you build them out, incorporate key elements and recommended practices for easier, more efficient execution and maintenance. With thoughtful development, test cases drive a robust approach to testing that increases your software quality and meets the expectations of your end users.

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback