是否可以直接执行非测试Apex代码?

问题描述 投票:0回答:1

我曾经用多种语言编写过很多代码,但对于Salesforce和Apex来说是新手。我看到Apex非常像Java。我看到可以在@IsTest Apex类中执行@IsTest方法的地方。但是,如何直接执行非测试代码呢?还是必须始终建立并解雇一份工作?还是使用Salesforce CLI和Apex插件在VSC中编写Java?是否有任何等效的“ Hello World”示例?

TIA,

仍然学习Steve

apex apex-code
1个回答
1
投票

在此处共享一个非常基本的示例

public class Stack {

    public static void printDetails(){
        system.debug('in static method');
    }

    public void printDetails1(){
        system.debug('in non static method');
    }

}

为了触发您创建的上述类,您可以使用开发者控制台开发者控制台->调试->打开“执行匿名窗口”,并插入以下行,然后单击执行

Stack.printDetails();
Stack s= new Stack();
s.printDetails1();

https://help.salesforce.com/articleView?id=code_dev_console.htm&type=5

© www.soinside.com 2019 - 2024. All rights reserved.