function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi,
Try the below code snippet For Test Method.
public class flagtst
{
public boolean flag;
public void testflag()
if(flag== false)
flag=true;
system.debug('_______check flag___________');
}
public static testMethod void CoverConstructor()
flagtst f=new flagtst();
f.flag=false;
f.testflag();
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi
I went through the same not too long ago, some pages that were usefull to me:
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests
http://shivasoft.in/blog/salesforce/step-by-step-salesforce-tutorial-%E2%80%93-creating-trigger-and-test-cases-%E2%80%93-6-of-6/
Once you've done the first, it gets easier :)
I have schedular for the below class,
please help how to write test class for this code.
global class cEMS_SAP_Report_Scheduler Implements Schedulable { global void execute(SchedulableContext sc) { cEMS_Controller_SAP cSAP = new cEMS_Controller_SAP(); cSAP.init(); List<Sap_Report_cems__c> lstSpekerReport = new List<Sap_Report_cems__c>(); String strSpeakerReport = 'Event ID,Event Start Date,Event End Date,Department,Cost Center,Applicant name,Applicant Date,Order Type,Company Code,Controlling Area\n'; for(integer i =0 ;i < cSAP.lstWrapEvent.size();i++) { Sap_Report_cems__c src=new Sap_Report_cems__c(); src.Event_ID_cems__c = cSAP.lstWrapEvent[i].EventId1; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].EventId1 + ','; src.Event_Start_Date_cems__c = cSAP.lstWrapEvent[i].eventStartDate; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].eventStartDate + ','; src.Event_End_Date_cems__c = cSAP.lstWrapEvent[i].EventendDate; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].EventendDate + ','; src.Department_cems__c = cSAP.lstWrapEvent[i].Department; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Department + ','; src.Description_cems__c = cSAP.lstWrapEvent[i].Objectives; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Objectives + ','; src.Cost_Center_cems__c = cSAP.lstWrapEvent[i].Costcenter; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Costcenter + ','; src.Applicant_cems_ref__c = cSAP.lstWrapEvent[i].ApplicantId; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Applicant + ','; src.Applicant_Date_cems__c = cSAP.lstWrapEvent[i].ApplicantDate; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].ApplicantDate + ','; src.Order_type_cems__c = cSAP.lstWrapEvent[i].OrderType; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].OrderType + ','; src.Company_code_cems__c = cSAP.lstWrapEvent[i].CompanyCode; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].CompanyCode + ','; src.Controlling_Area_cems__c = cSAP.lstWrapEvent[i].ControllingArea; strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].ControllingArea + '\n'; lstSpekerReport.add(src); } insert LstSpekerReport; Document doc = new document(); doc.Name = 'EMSSAP_' + system.now().format('dd/MM/yyyy hh:mm:ss') + '.csv'; doc.ContentType = 'text/csv'; doc.body = blob.valueof(strSpeakerReport); doc.folderid = [select id from folder where name='cEMS_SAP_Report'].id; // Stores in the currennt users "My Personal insert doc; } }
Hi,
Try the below code snippet For Test Method.
public class flagtst
{
public boolean flag;
public void testflag()
{
if(flag== false)
{
flag=true;
system.debug('_______check flag___________');
}
}
public static testMethod void CoverConstructor()
{
flagtst f=new flagtst();
f.flag=false;
f.testflag();
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi
I went through the same not too long ago, some pages that were usefull to me:
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests
http://shivasoft.in/blog/salesforce/step-by-step-salesforce-tutorial-%E2%80%93-creating-trigger-and-test-cases-%E2%80%93-6-of-6/
Once you've done the first, it gets easier :)
I have schedular for the below class,
please help how to write test class for this code.