Skip to content

Instantly share code, notes, and snippets.

View latentfuss's full-sized avatar

John Thompson latentfuss

View GitHub Profile
@latentfuss
latentfuss / myUnitTestTemplate.cls
Last active September 12, 2019 19:59
Here is a design pattern for unit tests that I have implemented in Eclipse as a template. The testSetupData() method validates that your @testsetup data is working correctly, and helps to mitigate the risk of changes to workflow, process, and validation in your Org
/**
* This class contains unit tests for validating the behavior of Apex classes
* and triggers.
*
* Unit tests are class methods that verify whether a particular piece
* of code is working properly. Unit test methods take no arguments,
* commit no data to the database, and are flagged with the testMethod
* keyword in the method definition.
*
* All test methods in an organization are executed whenever Apex code is deployed
@latentfuss
latentfuss / myClass.cls
Created August 2, 2016 15:37
how 2 pass boolean as argumnt in a method to return string
Public class myClass{
Public string myMethod(Boolean bool){
string returnString = ''; //declare return var
if(bool == null){ //check for null, not likely but could happen
returnString = 'You passed in a null Boolean! Stop the insanity!'; //alter return string if bool is null
} else if(bool == true){ //check for TRUE
returnString = 'You passed in TRUE'; //alter return string if bool is TRUE
} else if(bool == false){ //check for FALSE
returnString = 'You passed in FALSE'; //alter return string if bool is FALSE
}