You need to sign in to do that
Don't have an account?
Staci
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'; } }}
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
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);
}
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.