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
Cobb AndersonCobb Anderson 

executing several APEX unit test class coverage at once

hi devs!
I have one question regarding apex test class.
if I execute several test classes at once, how will the coverage calculate?
please tell me how the 75% coverage is consist of.
Is it the coverage of entire test class? or the last class that was executed in the row?
please help! T_T
RishavRishav
Hii cobb,
 if you execute several test class at once then all classes will execute one by one. And the test coverage will calculate per individual class.
You can also see the average percentage of the test coverage.
75% coverage is consist of per individual test class coverage. 
If you any test class that is not having 75% can't be deploy in the production.
Suppose you run multiple test class at once and your average is 80% but your one class is having only 60% test coverage then in that condition you won't be able to deploy your package in the production. Because in production environment every class is tested individually against its test coverage and if any class found less than 75% coverage then your deployment will be fail.

I hope you got it now .

Thanks 
Rishav
 
lkatneylkatney
Hey Guys,

It works with simple logic. Your production should have 75% or code coverage of all your classes and triggers(exclusing test classes). Salesforce check for average code coverage of all classes not for single class. It means if you already have 80% code coverage in prod and you are trying to deploy a class that has 0%, then salesforce will run all test classes and checks for average, If the y found it to be more than 75% or 75%, they will allow you to deploy else give you code coverage error.

When you run single classes or selected test classes, it gives results of those classes which they covered.

Hope this helps. Let me know if you have any further questions regarding this. I will give you documenatations regarding these concepts.