logo
  • 教程列表
  • SO官方文檔
  • Apex 測試
    • 使用 testSetup
    • 基礎測試類
    • 使用靜態塊
    • 斷言方法
    • 斷言方法
  1. StackOverflow 文件
  2. Salesforce 教程
  3. Apex 測試
  4. 使用靜態塊

使用靜態塊

Created: November-22, 2018

雖然你可以使用 @testSetup 批註指定在執行測試之前執行的方法,但此方法通常只執行一次。如果你需要在每次測試之前執行程式碼,則可以使用 static 塊:

@isTest
public class MyTest {
  static {
    // code here will be run before each test is executed
  }
}
  • 斷言方法
  • 基礎測試類

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明