Salesforce Developer Interview Question

What makes a good Apex test class, beyond reaching 75 per cent coverage?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Good tests prove behaviour rather than just executing lines. Create your own data through a test data factory instead of relying on org data, test with bulk records, assert specific outcomes for positive, negative and edge cases, and run as different users to check permissions. Use start test and stop test to reset limits and run async work, and mock callouts with HttpCalloutMock. Coverage is a side effect, not the goal.

Why interviewers ask this

Coverage requirements produce plenty of tests that execute code without checking anything, which gives false confidence and makes every deployment fragile. The interviewer wants to know whether your tests would actually catch a regression. They listen for meaningful assertions, bulk and negative cases, isolated test data, user context, and how you handle callouts and async code. Knowing that flaky tests block deployments shows experience.

How to structure your answer

  • Say why coverage alone is a poor target.
  • Describe test data creation and isolation.
  • Cover what you assert: positive, negative, bulk and permission cases.
  • Explain async code, callout mocks and keeping tests reliable.

Example answer

Spoken example, first person

The 75 per cent rule is a deployment gate, and it is easy to reach with tests that assert nothing, so I ignore it as a goal and ask whether each test would fail if the code broke. Every test class creates its own data through a test data factory and never relies on records that happen to exist in the org, because those differ between sandboxes and production. For each piece of logic I test the happy path with specific assertions on field values, a negative case where validation should block the save, and a bulk case with two hundred records to prove it stays within limits. Where permissions matter I use System.runAs with a restricted user. Tests cannot make real callouts, so I implement HttpCalloutMock with realistic responses, failures included, to exercise error handling. Async code goes between start test and stop test. I keep tests independent and deterministic, because every production deployment runs them, and one flaky test can block a release at the worst moment.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How would you test a trigger that calls an external API?
  • What goes in a test data factory, and why use one?
  • How do you cope with validation rules that admins add after your tests were written?

Related salesforce developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot