+ 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.