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
MANISHA AKHADEMANISHA AKHADE 

please help me for writing test class

Suraj Tripathi 47Suraj Tripathi 47
Hi 
MANISHA AKHADE,
This is my simple apex class where I update Opportunity.
public class UpdateOpp {
    public static void newUpdateOpp(){
            List<opportunity> opp = new List<opportunity>();
            opp = [Select Name, CloseDate from Opportunity WHERE CloseDate>TODAY];
            system.debug('opp' +opp);
            List<opportunity> opp1 = new List<opportunity>();
            for(Opportunity opp2:opp){
                opp2.Name = opp2.Name+'F';
                opp1.add(opp2);
                system.debug('opp1' +opp1);
                system.debug('+++++++++++' +opp);
            }
            update opp;
    }
}

Use the @isTest annotation to define classes and methods that only contain code used for testing your application.
In the test class, we have to cover at least 75% code to deploy the code into production.Here I write there Test class:
 
@isTest
private class UpdateOpp_Test {
    @isTest
    static void updateOppNew_Test(){
        opportunity opp1 = new opportunity();
        opp1.Name = 'F';
        opp1.CloseDate = system.today()+1;
        opp1.StageName = 'Close Won';
        insert opp1;
        
        Test.startTest();
        UpdateOpp.newUpdateOpp();
        Test.stopTest();
    }
}

please refer to the below link for more details.
https://trailhead.salesforce.com/content/learn/modules/apex_testing/apex_testing_intro
I hope you find the above solution helpful. If it does, please mark it as the Best Answer to help others too.
Thanks and Regards,
Suraj Tripathi
Robert Griffin 3Robert Griffin 3
This is not an easy task before you. Good programming skills and writing talent are needed here. If you doubt your abilities, then prepare your own version of the text and send it to the rewriting service https://www.rewritingservices.net/ These guys helped me a lot, I think it will be much easier for you to cope with your task with them too.