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
Amith RaoAmith Rao 

But how can i do 1% code coverage for the Trigger which does not have a helper class or method?

trigger checkboxupdate on Opportunity (Before insert) 
{ if(trigger.isInsert)               // While entering a new record in Opp
   {  for(Opportunity acc:trigger.new)
      { acc.IsPrivate=True;}
 }

If above is my code. How will be 1% code coverage for the Trigger which does not have a helper class or method ?  Please suggest for my question.
Best Answer chosen by Amith Rao
Amith RaoAmith Rao
Hi Mukesh,
Thankyou soo much for your reply.  Great . 
Please be in touch if you can share your mail Id or watsapp number for further help if i need.

Regards
Amith S Rao
9620588065-watsapp

All Answers

Mukesh_SfdcDevMukesh_SfdcDev
Hi Amith,

You have to just insert the opportunity into the test class then it will increase the code coverage.

Try this code,
@isTest
public class OppTrigerTest{

    public static TestMethod void OppMethodTest(){
    
        Account Acc = new Account();
        Acc.Name = 'Acc1';
        insert Acc;
        
        Opportunity Opp = new Opportunity();
        Opp.Name = 'TestOpp';
        Opp.AccountId = Acc.Id;
        Opp.StageName = 'Prospecting';
        Opp.CloseDate = System.today().addDays(10);
        
        insert Opp;
    }
}

Thanks 
Mukesh Kumar
Amith RaoAmith Rao
Hi Mukesh,
Thankyou soo much for your reply.  Great . 
Please be in touch if you can share your mail Id or watsapp number for further help if i need.

Regards
Amith S Rao
9620588065-watsapp
This was selected as the best answer