function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aditi Singh 54Aditi Singh 54 

Test class showing code coverage for classes not even called. My test class is showing 50%,25% code coverage for test classes not even made by me in the org. Will be greatful for help

AbhishekAbhishek (Salesforce Developers) 
This will help,

Increase code coverage

https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines

75 %

https://salesforce.stackexchange.com/questions/24165/why-is-75-code-coverage-required-in-salesforce/24167#24167


If it helps you and closes your query by marking it as solved so that it can help others in the future.

Thanks.
Aditi Singh 54Aditi Singh 54
Thanks for reply, but it is showing code coverage for those classes which are not even called by test class and even don't have any parent child  relation.
Aditi Singh 54Aditi Singh 54
A bit of explanation of my problem:
Suppose I am calling class B between test.startTest() and test.stop() but my test is failing because of some X class error
 
SUCHARITA MONDALSUCHARITA MONDAL

Hi Aditi,

There are some possibilities when different classes are covered using single test class.

1. If both classes are sharing same methods/or have some references to each other.
2. If One class is sub class/wrapper class in another class
3. If you have one test class for covering different -different aprx classes.
 

PS. Also it's good to have one test class to cover multiple controller classes are the same time. So that we can reuse those test classes. Read the concept of TestFactory Classes.

https://trailhead.salesforce.com/en/content/learn/modules/unit-testing-on-the-lightning-platform/generate-data-for-tests

Hope this helps!
Thanks,
Sucharita