OBLYTECH Logo
OBLYTECH Logo

Apex Test Coverage Review Before Release

An Apex test coverage review before release checks whether the test classes prove the behavior of each changed class and trigger, not just whether the lines ran. Map each changed unit to a test method, confirm the assertions match the expected results, cover bulk and negative cases, and record any accepted gaps before the release is approved.

Why a coverage percentage cannot carry the release decision

The coverage figure reports which lines ran during a test run. It says nothing about whether those lines produced the right result. A test that calls a method, ignores what comes back and does not check a field value adds lines to the count and protects very little.

The review therefore asks a different question for each changed piece of logic: which test would fail if this logic broke? When the honest answer is no test, the release carries unverified risk, whatever the percentage shows. A high figure can start the conversation, but it should not end it.

Build the list of changed triggers and classes from the release scope

Start from the release scope rather than from the test folder. Pull the list of Apex classes and triggers that differ from the last production deployment, using the same version control history the team used to build the release. Then add the helper classes those files call. Regressions often come from a shared utility class used in three places, which nobody listed because the change to it looked small.

Group the changed units by the business process they serve. A lead conversion change, a case escalation change and a billing rollup change each need their own expected results and often their own reviewer. A single test class that exercises all three hides which assertion protects which process, and it makes failures harder to read when they arrive.

Check each unit against this list:

  • The file appears in the release list, or there is a written reason it does not.
  • Each class that a changed trigger or class calls is listed, even if its own code did not change.
  • Scheduled, queueable and batch classes are flagged, because they run outside a user’s transaction and their failure paths are often untested.
  • A named business owner is recorded for the process, so questions about expected results have an answer.

Recording the business purpose of each class during needs assessment and discovery gives the review something concrete to test against. If nobody on the team can say what a class is for, that gap is a discovery problem before it is a testing problem.

Map each changed unit to the test methods that reach it

With the list in hand, find the test methods that exercise each changed unit. Search the test classes for the class name, and for the object a trigger fires on, because a test that inserts an account runs the account trigger whether or not its name mentions accounts. Record the mapping in a table with three columns: the changed unit, the test method that reaches it, and the assertion that would catch a regression in that unit.

A changed unit with no mapped test method stops the review for that unit. Either the test gets written before the release, or the gap is accepted in writing, with the name of the person who accepted it and the reason.

Read the assertions, not just the setup and execution

The core of the review is reading each test method from its final lines backward. A sound test sets up a known state, performs one action and checks a specific outcome: a field value, a record count, a status, or an error with the expected message. An assertion that confirms merely that a value is not null, or that a list is not empty, passes for many wrong outcomes and should be tightened.

Look for these weak patterns during the read:

  • Assertions that compare a value the test itself set, which prove nothing about the code under test.
  • Catch blocks that swallow an exception, so the test completes as a pass.
  • Database operations whose result the test does not check, so a failed save goes unnoticed.
  • Test methods with no assertions, which add coverage lines without checking any behavior.
  • Assertions placed before the action they are meant to verify.

Where the expected result is unclear, do not let the developer who wrote the change decide it alone. Both people can share the same misunderstanding. The business owner for the process should confirm the expected value in writing, and the assertion should be rewritten to match that confirmed value.

Cover bulk, negative and permission paths in each changed trigger

A test that inserts a single record misses a whole class of trigger failure. For each changed trigger, confirm there is a test that sends a batch of records through the same code path, and that its assertions cover each record in the batch rather than the first one. A loop that handles one record correctly and skips the rest is a common cause of failures during data loads. Bulk coverage matters especially on the paths that data migration and integration jobs use, since those jobs send large volumes through the same triggers.

Negative cases need the same attention. For each validation or rule the change adds or alters, write or confirm a test that submits input which should be rejected. Assert the rejection and the message the user receives, rather than just that an exception occurred. A test that proves a bad record is refused tells you more than one that proves a good record saves.

Permission paths matter where the logic branches on who is running it. Run the relevant tests as users whose profile and permission sets match real roles, and check the result each role should get. A test run as an administrator alone can pass while a standard user hits an access error in production. Where sharing or field visibility matters, state which role the test checks.

Keep test data inside each test and free of hidden dependencies

Create the records each test needs inside that test, rather than reading records that happen to exist in one sandbox. Tests that depend on existing data break when an environment is refreshed or when another team removes records, and they generate false failures that people learn to ignore. Build just the fields the logic reads.

Check also for order dependence. A test that relies on a record created by a different test is a hidden dependency. It may pass in one run and fail in the next, depending on the order in which tests execute.

Where the release changes behavior that depends on configuration, such as a record type, a status value or a required setting, write a note in the review that the test assumes that configuration. Then confirm the target environment holds the same configuration before the release. Sandbox refresh planning is where the team confirms which configuration the target environment will hold after a refresh.

Turn the review into a release gate with a named owner

Make the review a gate with one person responsible for it. Before the release is approved, the release lead should hold a document that lists each changed unit, the test methods that cover it, the assertion that protects its key behavior, and any accepted gaps with a name beside each one.

Run the full test suite in a staging environment that matches production as closely as the release plan allows. Record the results, including failures that existed before the release, so the release is not blamed for them and they are not forgotten. Treat each failure as information. Find out whether it comes from the release, from test data, or from a difference between environments. If a test was disabled to get the release through, the review should record the reason and the date it will be restored.

Before the staging run, read the platform release notes for anything that touches the classes, triggers or objects under test. The review of administrator release notes before each sandbox test sets out what to look for in that step.

Use the following sequence for each release:

  1. Confirm the changed unit list against the release scope.
  2. Confirm each changed unit has a mapped test method with a specific assertion.
  3. Confirm bulk, negative and permission cases for each changed trigger and validation.
  4. Run the full suite in staging and record the results with any pre-existing failures.
  5. Collect written sign-off from the business owner for each process in the release.

For help planning this work, see Salesforce implementation.

Questions about reviewing Apex tests before a Salesforce release

How many test methods should a changed trigger have?

There is no fixed number. Count the distinct behaviors the trigger produces. Each branch that changes a field, creates a related record or blocks a save usually needs its own test method with its own assertion. A single method that covers several branches tends to hide which one broke.

How long should the review take for a small release?

For a release that changes one or two classes, the mapping and the assertion read often fit in a focused session, provided the business owner is available to confirm expected results. Much of the time goes into agreeing expected results. If confirmation takes days, name that delay as a schedule risk early.

Should a developer review the tests they wrote?

The author can run the first pass, but a second person should read the assertions. The author knows what the code is meant to do and may check the same behavior they built. That overlap is the blind spot a review exists to catch.

Who should own the test standard over time?

Assign the standard to the team that owns the platform roadmap, so new triggers follow the same rules as existing ones. Standards of this kind sit alongside the order of platform changes, which the Salesforce strategy and roadmap development work sets out.