What to test
- Single action
- Bulk action
- Positive action
- Negative action
- Restricted users
(HINT:- write test cases with different positive and negative numbers as input)
(HINT:- Sometimes the results are not expected so in that case change the original class )
**Minimum Test coverage in SF Apex is 75%
**System.assert() etc but use Assert class for testing
----------------------------------------SOQL-----------------------------------
IN , LIKE, LIMIT, OFFSET
// Get latest 5 records and skip first 5
SELECT Name, Status, LeadSource, CreatedDate FROM Lead ORDER BY CreatedDate DESC LIMIT 5 OFFSET 5
Date Literals
In SOQL, date literals make it easy to filter data based on dynamic or specific date ranges without having to calculate exact dates manually. These literals work with date, datetime, and time fields and are particularly useful in WHERE clauses. Here’s a breakdown of commonly used date literals in SOQL:
Commonly Used Date Literals
Today and Relative Days
TODAY: Represents the current day.YESTERDAY: Represents the day before today.TOMORROW: Represents the day after today.
Relative Days
LAST_N_DAYS:n: Represents the last n days, including today.NEXT_N_DAYS:n: Represents the next n days, including today.N_DAYS_AGO:n: Represents n days ago from today.
Relative Weeks
THIS_WEEK: Represents the current calendar week (Sunday through Saturday).LAST_WEEK: Represents the previous calendar week.NEXT_WEEK: Represents the upcoming calendar week.
Relative Months
THIS_MONTH: Represents the current calendar month.LAST_MONTH: Represents the previous calendar month.NEXT_MONTH: Represents the upcoming calendar month.LAST_N_MONTHS:n: Represents the last n months, including the current month.NEXT_N_MONTHS:n: Represents the next n months.
Relative Quarters
THIS_QUARTER: Represents the current calendar quarter.LAST_QUARTER: Represents the previous calendar quarter.NEXT_QUARTER: Represents the upcoming calendar quarter.LAST_N_QUARTERS:n: Represents the last n quarters.NEXT_N_QUARTERS:n: Represents the next n quarters.
Relative Years
THIS_YEAR: Represents the current calendar year.LAST_YEAR: Represents the previous calendar year.NEXT_YEAR: Represents the upcoming calendar year.LAST_N_YEARS:n: Represents the last n years.NEXT_N_YEARS:n: Represents the next n years.
Fiscal Periods
THIS_FISCAL_QUARTER: Represents the current fiscal quarter.LAST_FISCAL_QUARTER: Represents the previous fiscal quarter.NEXT_FISCAL_QUARTER: Represents the upcoming fiscal quarter.THIS_FISCAL_YEAR: Represents the current fiscal year.LAST_FISCAL_YEAR: Represents the previous fiscal year.NEXT_FISCAL_YEAR: Represents the upcoming fiscal year.LAST_N_FISCAL_YEARS:n: Represents the last n fiscal years.NEXT_N_FISCAL_YEARS:n: Represents the next n fiscal years.
Example Query Using Multiple Date Literals
Get opportunities closing in the current quarter:
These literals make it easy to write dynamic, date-based SOQL queries without worrying about specific date calculations. Let me know if you’d like more examples with specific date types!
Comments
Post a Comment