Skip to main content
Mohankumar B 님이 #Data Management에 질문했습니다
How to write the test class for @AuraEnabled Method anyone help me this one??

 

@AuraEnabled

 

    public static void PerSFTVersion(Id artId) {

 

        List<Quote> lstQuoToUpdate = new List<Quote>();

 

        for(Quote Qu : [select id,Version__c from Quote where id =: artId]){

 

            decimal count = Qu.Version__c;

 

           If((count == Null)){

 

                Qu.Version__c = 1;

 

                lstQuoToUpdate.add(Qu); 

 

            }

 

             If((count != Null)){

 

                count++;

 

            system.debug('count++'+ count);

 

            Qu.Version__c = count;

 

            lstQuoToUpdate.add(Qu); 

 

            }

 

        } 

 

        

 

        if(lstQuoToUpdate.size() > 0){

 

            update lstQuoToUpdate;

 

        }

 

        

 

    }
답변 5개
  1. 2020년 10월 7일 오전 7:22
    Hi 

     

    This is same writting test class for any other static method .

     

    For your test class 

     

    Create method and create data for Quote  object .

     

    insert that data and get id of inserted record.

     

    and call Auramethod as follow .

     

    Lets say your class name is MyAura  in which you have written aura method.

     

    then call that method like

     

    MyAura.PerSFTVersion(artId);

     

    Please let me know if its works.
0/9000