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
Vegaln1Vegaln1 

How Do I determine which trigger is causing this error in 'APEX Class -> Run All Tests'

Under the section of 'Test Coverage Warnings' how do you tell what trigger is assocated with the warning Message:

 

 

Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

 

Is it entirely going through each trigger manually or is spelled out it the test results some where. We have several triggers and the list of debug information is quiet long.

 

Regards

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

It appears that if you don't have any unit test code exercising a trigger, you don't get the name appearing in the trigger code coverage section.

 

I've got a dev org with a couple of triggers that I've written no unit test code for, and I get two instances of "Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required" at the end of the report, with no mention of their names.

 

I reckon you'll need to look at your defined triggers and find which one doesn't appear in the unit test report - as you only have one line in the report, it sounds like you've only got one trigger that's a problem!

 

 

 

All Answers

bob_buzzardbob_buzzard

When you say 'APEX Class -> Run All Tests', are you running all tests for a single Apex class, or all tests for all Apex classes.

 

If the former, the warning is telling you that the unit tests present in that single class are causing a trigger to be executed.  This isn't a problem, as long as you have some unit tests elsewhere that do cause the trigger to be executed.  If you run all the unit tests that you have from your org web site (Setup -> Develop ->Apex Classes and click the Run All Tests button), you will generate a report showing the percentage coverage of all classes and triggers.

 

If the latter, you can run the tests from the org web site as above.

Vegaln1Vegaln1

Thank you for response. I was running from Setup -> Develop ->Apex Classes and clicking the 'Run All Tests button'.

 

 

Regards,

bob_buzzardbob_buzzard
Scroll down the resulting page to the section entitled "Code Coverage" - there is a subsection entitled "Trigger Code Coverage" that shows which of your triggers are missing tests.
Vegaln1Vegaln1

 

 

Trigger Name Coverage % CasePopulateProduct 88 OppLine 100 ContactCheckActiveStatus 100 ValidateContractDelete 100 AssetEntitlement 100 Att_On_CP 98 AutoCreateAssetEntitlement 100 RunEntlShipToUpdate 90 RollUp 100 ValidateSHipToDelete 100 CP_Case_Comment 81 AutoCreateContract 100 ValidateContact 100 RunShipToUpdate 90 ValidateAggUpdate 86 Case_Open_Date 75 ValidateEmailChangeOnContact 100 ContractUpdateAEs 92 shareAccountHier 100 CheckContractToCurrent 88 Test Coverage Warnings Message Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

 That's what is puzzling me.The Trigger code coverage looks decent but yet there appears to be a trigger that has no test code for it but the logs don't appear to say which one.

 

Regards,

bob_buzzardbob_buzzard

It appears that if you don't have any unit test code exercising a trigger, you don't get the name appearing in the trigger code coverage section.

 

I've got a dev org with a couple of triggers that I've written no unit test code for, and I get two instances of "Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required" at the end of the report, with no mention of their names.

 

I reckon you'll need to look at your defined triggers and find which one doesn't appear in the unit test report - as you only have one line in the report, it sounds like you've only got one trigger that's a problem!

 

 

 

This was selected as the best answer
Vegaln1Vegaln1

I think you're right.

 

Thanks.

 

Regards