Giter VIP home page Giter VIP logo

Comments (7)

daphne-sfdc avatar daphne-sfdc commented on July 18, 2024 1

Hi @amtrack,

I spoke to my team today and received confirmation that this is working as designed. I spent some time to study the code and run tests on it in dreamhouse-lwc - thank you for pointing me to the getAggregateCodeCoverage() function - and discovered this is not an easy fix. This is how the code coverage currently works:

After the Apex test run completes, the results are passed into formatAsyncResults() in asyncTests.ts. If you ran the tests with the --code-coverage flag, the check in Line 258 is True, and the code for formatting code coverage is run. If you run the Apex tests with the "Store Only Aggregated Code Coverage" box checked in the Apex Test Execution page, the perClassCovMap is set to an empty map, which means coveredApexClassIdSet is an empty set, as the values are populated to coveredApexClassIdSet during the calculation of per class code coverage. coveredApexClassIdSet is passed as parameter into getAggregateCodeCoverage(). In Line 107, we have the if (apexClassIdSet.size === 0) { validation, which returns empty code coverage results if apexClassIdSet is empty, which is True in this case. That's why the "Apex Code Coverage by Class" section of the Apex test results doesn't have a table.

The Apex classes listed in the "Apex Code Coverage by Class" table are the classes that are covered by the Apex tests in the current test run. That set is identified by the calculation of per class code coverage and cannot be inferred otherwise from the Apex test run. One alternative is to list all Apex classes present in the org in that table, since the "Store Only Aggregated Code Coverage" setting is designed to be used for large test runs, which often refers to all the Apex test classes in a given org. However, that would limit the results from when that setting is checked to only make sense in one use case.

Our team does agree that while the feature is working as originally designed, it's not intuitive, and thus we are currently investigating this issue to understand the alternatives for displaying useful information in the "Apex Code Coverage by Class" table. In the meantime, please continue to use your workaround, and we will keep you updated with our findings. Thank you for your patience.

from salesforcedx-vscode.

git2gus avatar git2gus commented on July 18, 2024

This issue has been linked to a new work item: W-15783639

from salesforcedx-vscode.

daphne-sfdc avatar daphne-sfdc commented on July 18, 2024

Hi @amtrack, Thank you for filing this issue. Yes, this is a bug, and I was able to reproduce it in my environment with a large project containing 4000 Apex classes and 4000 Apex test classes and the dreamhouse-lwc sample project. As my team member @peternhale responded to your previous issue, we have work in our backlog for handling large Apex test runs, and we will work on this bug as part of that effort.

Thank you for your patience. We'll keep you updated when we have more progress on resolving your issue.

from salesforcedx-vscode.

amtrack avatar amtrack commented on July 18, 2024

@daphne-sfdc Just to double-check, this ticket here isn't related to large codebases, it is only related to the Test Execution setting "Store Only Aggregated Code Coverage".
The reproduction has only 2 ApexClasses, 1 is a test class.
I think this could be a quick fix.

10:41:26.843] DEBUG (sf:elapsedTime): CodeCoverage.getAggregateCodeCoverage - enter
[10:41:26.843] DEBUG (sf:elapsedTime): CodeCoverage.getAggregateCodeCoverage - exit
    elapsedTime: 0.176333

Maybe the getAggregateCodeCoverage is called without apex class ids and returns immediately with an empty response: https://github.com/forcedotcom/salesforcedx-apex/blob/b3ede186ad57af393ef2d200bdadaebe2ada3c84/src/tests/codeCoverage.ts#L102

from salesforcedx-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.