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
justinpauldavis10justinpauldavis10 

Test coverage

I'm having difficulty installing this trigger:

 

 

trigger SetAccountField on Account__c (before insert, before update) {
    for (Account__c Account__c : Trigger.new) {
        Account__c.Scoring__c = 'a00A0000003MnLw';
    }
 }

 

 

Essentially, it updates the lookup field Scoring__c on a custom object called Account.

 

I'm getting there error: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required.

 

What additional code am I missing to facilitate test coverage?

 

Thanks for any help anyone might have

Shailesh DeshpandeShailesh Deshpande

you just need to create & update an Account__c...and run tests for this class

 

 

@isTest
private class Test_class
{
    static testMethod void test()
    {
        // TO DO: implement unit test
                     
        Account__c objAccount = new Account__c();
        objAccount.name = 'A';

         // other mandatory fields
        insert objAccount;

 

        objAccount.name = 'B';
        update objAccount;

   }

 }