You need to sign in to do that
Don't have an account?
Sara Burch 20
How to develop a test class
Hello everyone, I successfully create a form of record views of users and now cannot deploy in my production org without a test class. I've searched all day for a sample test that can help explain what I am to do, no luck!
Here is my class code:
Here is my class code:
public class lastViewed{ public Datetime cDT; public String LongDate; public String firstname; public String lastname; public String userid; private final Chalkboard_Manager__c acct; public lastViewed(ApexPages.StandardController stdController) { this.acct = (Chalkboard_Manager__c)stdController.getRecord(); } public String getLongDate() { cDT = System.now(); //Format the datetime value to your locale LongDate = cDT.format('dd/MM/yyyy HH:mm'); return LongDate; } public void updateField() { //Get the user info from the current user firstname = System.Userinfo.getFirstName(); lastname = System.Userinfo.getLastName(); userid = System.Userinfo.getUserId(); //Get the chalkboard record to be updated Chalkboard_Manager__c a = [select Last_Viewed_By__c from Chalkboard_Manager__c where id = :acct.id limit 1]; //Assign values to Last Viewed By field & update the record a.Last_Viewed_By__c = (firstname + ' ' + lastname + ', ' + getLongDate()); update a; } }
Please check sample code below :
Hope this helps you.
Please let me know in case of any other assistance.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
All Answers
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
If you're on Trailhead though, you might want to start here:
https://trailhead.salesforce.com/modules/apex_testing
Please check sample code below :
Hope this helps you.
Please let me know in case of any other assistance.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com