Enhancement: option to always display latest code coverage results in editor

Issue #2408 duplicate
Kevin Poorman created an issue

As a user, I love to open two panes; on the left - my production code, and on the right the tests for that class. I’d love the ability to configure IC2 to automatically display the latest code coverage for a file, if it exists, so that my code coverage is automatically displayed when I run tests.

Comments (12)

  1. Scott Wells repo owner

    If you execute tests using Run With Coverage, it will download coverage metrics and overlay them in the IDE immediately upon completion of the tests:

    Does that meet the request?

  2. Kevin Poorman reporter

    ah. i’ve been running via the green triangle. I assumed that since I’ve set the checkbox to always get coverage that it would auto show it. It’s not here, but I see the green triangle has the option to run with coverage so perhaps it’s ignoring that flag?

  3. Scott Wells repo owner

    If you want coverage to show immediately after test execution, you must use the Run With Coverage action. That’s just part of the underlying JetBrains IDE test/coverage framework:

    https://www.jetbrains.com/help/idea/running-test-with-coverage.html

    Doing so will execute the Apex tests denoting that coverage should be collected during test execution. That’s an API option and adds a very small amount of overhead to test execution, so it’s disabled by default. If you want all test executions to gather coverage, you can check the option in the screenshot above, but that will just ensure that it’s gathered on the server. It won’t automatically display coverage in the IDE upon completion unless you use the Run With Coverage action.

  4. Kevin Poorman reporter

    Gotcha. Thats, odd. I think. not sure why jet brains would make showing coverage a two step process if you’ve configured it to always get the coverage data.

  5. Scott Wells repo owner

    Always collect coverage is a Salesforce-specific option that just tells the server to measure coverage metrics during test execution no matter how you run tests. It doesn't cause anything to happen in the IDE locally. It's basically the exposure of a REST API option for the unit test API. Does that help clarify it?

  6. Kevin Poorman reporter

    yep. I totally get the distinction between the ‘always enable collection’ and ‘actually get the coverage info’. I think what’s odd, to me, is that jet brains would handle it this way. When would i not want coverage info?

  7. Scott Wells repo owner

    Ah, I see. I run unit tests all the time in the Java world without checking coverage. I circle back around to look at coverage once I have a set of tests laid out the way I want, and that can often take multiple iterations. But I get your point…it would be nice if you could designate Run With Coverage as the default behavior. And maybe you can. I'd have to dig around and see if such an option already exists. Wouldn't surprise me if it does. I'll let you know.

  8. Log in to comment