The Salesforce Developer Console only highlights lines of Apex code executed when a test class's assertions pass.

Is there any IDE for Apex development that will show me which lines of code executed & which didn't when a test class's assertions fail, so I can find my coding mistake faster?

Right now, I'm running the test with all System.assert statements commented out but it feels kludgy. Is there a better way?

  • 1
    When unit tests run, they always show which lines were covered, even if the test fails because of an assert or other reason. Can you provide an example where you're not getting the results you expect?
    – sfdcfox
    Mar 7, 2016 at 20:40
  • Weird...my "Developer Console" has always insisted 0% code coverage for the code invoked by a unit test if the unit test's assertions fail. I'm working on a simple piece of code to add to the question.
    – k..
    Mar 7, 2016 at 22:03
  • Hmm. I just mocked up a simple 10-liner and I see what you're saying (100% coverage, from the test class invoking it) even when FALSE=TRUE), but for some reason my "real code" (which does involve one more layer - a trigger) doesn't behave the same way (0% coverage), not has most other larger code I've ever written. (That is, unless I turn off all the failing asserts.) Not sure where to go from here right now...I don't yet have sample failing code that isn't too internal to share.
    – k..
    Mar 7, 2016 at 22:15
  • @k.. The trick with unit tests on triggers is that your unit test must do something to cause the trigger to fire. IE- if we're doing a "before insert" trigger on an account, we need to insert an account in the test class. Make sense? If you give me an idea of the contents of your trigger I can help you with a test class for it. Edit: Also, if there's conditional logic in the trigger you need to make it fire for each fork of the logic to get a full test.
    – bcarlock
    Mar 7, 2016 at 22:25
  • Aaaand it's working now. Maybe I just got convinced it'd "always" been broken because I was frustrated. It was definitely broken, but then again, so were many other things (like save timeouts). Thanks all for the answers.
    – k..
    Mar 8, 2016 at 15:32

2 Answers 2


Have you tried using the Force.com Eclipse IDE? I do pretty much all of my development in there and it's always been laser accurate as to where my issues are. https://developer.salesforce.com/page/Force.com_IDE

  • Okay, looks like that is getting the code coverage right during failing assertions. And if I take the time to update my install, looks like I can even get highlighting. Slow piece of software for certain tasks compared to the Developer Console, and now I'm curious why everyone else's Developer Console does code coverage correctly during failing assertions & mine doesn't, but you did answer my question. :-)
    – k..
    Mar 7, 2016 at 22:22
  • Yeah, Eclipse definitely isn't the fastest, but so far as I've seen it's the best thing out there.
    – bcarlock
    Mar 7, 2016 at 22:28

After running unit tests it should always show you which lines were covered and which not in Developer Console. Also there is nice IDE that can do the same - The Welkin Suite, you might want to check it.

  • Really? Mine has never shown me such coverage unless the assertions pass. Working on something to add to the question...
    – k..
    Mar 7, 2016 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .