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.
-
what is the issue? if you have written code for test method post that along with class code– Manjot SinghJul 14, 2017 at 13:03
1 Answer
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.
-
@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.– emyJul 18, 2017 at 7:00