This Gist shows code examples for Apex Testing Best Practices. It relys on having the TestFactory in your org.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from http://wiki.developerforce.com/page/Apex_Design_Patterns_-_Singleton | |
// What makes this a singleton pattern? Is it that it uses a private constructor? | |
public class AccountFooRecordType { | |
// private static variable referencing the class | |
private static AccountFooRecordType instance = null; | |
public String id {get;private set;} // the id of the record type | |
// The constructor is private and initializes the id of the record type | |
private AccountFooRecordType(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Opportunity" | |
extensions="OpportunityNewDispatcherController" | |
action="{!redirect}"> | |
</apex:page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="SuperDuperSettingController"> | |
<apex:pageMessages /> | |
<apex:form > | |
<apex:pageBlock > | |
<apex:pageBlockSection > | |
<apex:pageBlockSectionItem > | |
<apex:outputLabel >Name</apex:outputLabel> | |
<apex:inputText value="{!setting.Name}"/> | |
</apex:pageBlockSectionItem> | |
<apex:pageBlockSectionItem > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SchedulableDemo implements Schedulable{ | |
public Integer counter; | |
public void execute(SchedulableContext sc) { | |
if (counter == null) { | |
counter = 1; | |
} else { | |
counter ++; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page> | |
<head> | |
<apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / > | |
<apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" /> | |
<apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" /> | |
<!-- I have a static resource called famfamfam which is the zip file from http://www.famfamfam.com/lab/icons/silk/famfamfam_silk_icons_v013.zip --> | |
<style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Package xmlns="http://soap.sforce.com/2006/04/metadata"> | |
<types> | |
<members>Accounts_with_Leads_2</members> | |
<members>Accounts_with_leads</members> | |
<name>ReportType</name> | |
</types> | |
<version>38.0</version> | |
</Package> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<messaging:emailTemplate subject="{!SUBSTITUTE($Label.AccountEmailSubject,'{0}', relatedTo.Name)}" | |
relatedToType="Account" language="{!relatedTo.Language__c}"> | |
<messaging:htmlEmailBody > | |
{!$Label.EmailBody} | |
</messaging:htmlEmailBody> | |
</messaging:emailTemplate> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DynamicEmailController { | |
public DynamicEmailController() {} | |
public String emailRelatedToId {get; set;} | |
public String emailTemplateId {get; set;} | |
public Boolean isHtml {get; set;} | |
private Messaging.SingleEmailMessage renderedEmail { | |
get { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Package xmlns="http://soap.sforce.com/2006/04/metadata"> | |
<types> | |
<members>*</members> | |
<name>Profile</name> | |
</types> | |
<types> | |
<members>MyTab</members> | |
<name>CustomTab</name> | |
</types> |
OlderNewer