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
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.
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
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.
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.
Suppose I am calling class B between test.startTest() and test.stop() but my test is failing because of some X class error
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