Achieve your business goals faster by unlocking our Salesforce Cloud Services.
The common system-defined unit test methods are:
Purpose:
Any code that executes after the call to start test() and before stop test () is assigned a new set of governor limits.
Any code that executes after the call to stop test() is arranged the original limits that were in effect before start test() was called.
Ex:
@isTest
private class myClass {
static testMethod void myTest() {
// Create test data
………
Test.startTest();
// Actual apex code testing
Test.stopTest();
}
This method returns true if the currently executing code was called by code contained in a test method, otherwise false.
public class PositionTriggerHandler{
public static void processUpdatedRecords(List<Position__c> updateList) {
if (Test.isRunningTest()) {
//unit testing alternative code goes here
else {
//execute normally
This method defines a list of fixed search result IDs which are then returned as results in SOSL statements in a test method.
private class SoslFixedResultsTest1 {
public static testMethod void testSoslFixedResults() {
Id [] fixedSearchResults= new Id[1];
fixedSearchResults[0] = ‘aOOx0000003G89h’;
Test.setFixedSearchResults(fixedSearchResults);
List<List<SObject>> searchList = [FIND ‘Salesforce’
IN ALL FIELDS RETURNING
Position__c(id, name WHERE name = ‘Salesforce’ LIMIT 1)];
setCurrentPage and setCurrentPageReference are Visualforce test methods that set the current PageReference for the Visualforce controllers.
We will learn about these methods in the coming chapters.
< < Previous
Next > >
The batch is going to start shortly. Fill the form given below to Register yourself now.
Fill the form below to get a Result
Fill the form below to get a demo of this course.
Online Salesforce Development Course is soon going to be launched. Please fill the form and we will notify you about the course.