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
StaciStaci 

Test Classes

I'm being asked to write test classes for my apex code and I guess I just don't understand how to write it.  How do you write a test code for this?

 

Any help is greatly appreciated.  Reading An Introduction to Apex Code Test Methods is like listening to Charlie Brown's teach talk, it makes no sense to me...

 

public with sharing class cancelChange {
public Boolean isDisplayPopUp {get; set;} 
    public cancelChange(ApexPages.StandardController controller) {

    
isDisplayPopUp = true;    
{Change__c chge = (Change__c) controller.getRecord(); chge.StatusChange__c = 'Cancelled'; }   
}}

 

Best Answer chosen by Admin (Salesforce Developers) 
asish1989asish1989

private class TestControllerCreateAdhocInvoice {
static testMethod void CreateAdhocInvoice() {
Change__c chge = new Change__c() ;
chge.Name = 'test';
// also bind some required fields
insert chge;
ApexPages.Standardcontroller standardController1 = new Apexpages.Standardcontroller(chge);
cancelChange clsobj = new cancelChange(standardController1);
}

All Answers

asish1989asish1989

private class TestControllerCreateAdhocInvoice {
static testMethod void CreateAdhocInvoice() {
Change__c chge = new Change__c() ;
chge.Name = 'test';
// also bind some required fields
insert chge;
ApexPages.Standardcontroller standardController1 = new Apexpages.Standardcontroller(chge);
cancelChange clsobj = new cancelChange(standardController1);
}

This was selected as the best answer
StaciStaci
thank you so much asish! Is there some Test Classes for Dummies articles?
asish1989asish1989

Go through my all post , I have given lots of answer regarding test classes, You can also search in google you will get more help.