0

I am facing issue in writing test class that has 1 method which only executed when the lightning buttons get clicked.please suggest on this issue. Any help would be appreciated.

1
  • what is the issue? if you have written code for test method post that along with class code Commented Jul 14, 2017 at 13:03

1 Answer 1

3

You test an @AuraEnabled by calling it directly from your test:

public YourClass {
    @AuraEnabled
    public static String doSomething() {
        ...
    }
}

@IsTest
private YourClassTest {
    @IsTest
    static void testDoSomething() {
        System.assertEquals('...', YourClass.doSomething());
        ...
    }
}

The serialization to and from the client parts is handled by the platform and does not need to be tested by you.

Only if your @AuraEnabled method makes its own HTTP callouts would also need to setup a HttpCalloutMock.

1
  • @auraenabled public void getAllinfo(){ public void getCalloutsMethods(){} public void getButtonClickMethod(){}}@auraenabled public void getButtonClickMethod(){} But I am using this method inside a method.Can you help me on this.
    – emy
    Commented Jul 18, 2017 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .