準備階段
安裝Visual Studio Code
https://code.visualstudio.com/
安裝salesforce 指令行工具
https://developer.salesforce.com/tools/sfdxcli.
驗證安裝是否正确
在windows指令行 輸入指令
sfdx update
安裝插件
在Visual Studio Code中的Extension中搜尋相關插件安裝
插件 :salesforce extension pack
Apex Replay Debugger
安裝java ide
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
配置java環境
1,In Visual Studio Code, click File > Preferences > Settings (Windows or Linux) or Code > Preferences > Settings (macOS).
2,Enter apex java in the search box, then under the Salesforcedx-vscode-apex > Java: Home section, click Edit in settings.json.
3,change salesforcedx-vscode-apex.java.home like this ,then relunch.
{
"salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Java\\jdk1.8.0_191",
"explorer.confirmDelete": false,
"force.autoRefresh": true
}
Debug階段
運作測試
SFDX: Invoke Apex Tests
設定斷點和觀察點
Debug: Toggle Breakpoint
SFDX: Toggle Checkpoint
設定觀察點後,要把設定的觀察點部署到系統
SFDX: Update Checkpoints in Org
設定斷點和觀察點後,打開生成Debug log 開關
SFDX: Turn On Apex Debug Log for Replay Debugger
擷取Debug log文檔
SFDX: Get Apex Debug Logs…
Log存放目錄
.sfdx/tools/debug/logs
右鍵點選目錄中任意一行,然後執行下面指令,就可以進行debug
SFDX: Launch Apex Replay Debugger with Current File.