You need to sign in to do that
Don't have an account?
Akhil Katkam 5
Test Class for this RSSFEEDCTRL
Hi Developer community ,
i have an apex class , i am having only little knowledge on test classes ,
can u please write test class for below apex code
Thanks in Advance
i have an apex class , i am having only little knowledge on test classes ,
can u please write test class for below apex code
public class RSSFeedCtrl { @AuraEnabled public static String getURL(String URLField, ID recordId, String objectName) { String queryString = 'select ' + URLField + ' from ' + objectName + ' where Id = \'' + recordId + '\''; String returnValue = ''; try { sObject s = Database.query(queryString); returnValue = (String)s.get(URLField); } catch (Exception e) { throw new AuraHandledException('Error in getURL method of RSSFeedCtrl: ' + e.getMessage()); } return returnValue; } @AuraEnabled public static List<RSSObject> getRSSFeed(String url) { List<RSSObject> toReturn = new List<RSSObject>(); try { if(url != null){ toReturn = RSSFeedUtil.getGoogleRSSObjects(url); } } catch (Exception e) { throw new AuraHandledException('Error in getRSSFeed method of RSSFeedCtrl:' + e.getMessage()); } return toReturn; } }
Thanks in Advance
Before use the below test class you need the mock class i have already posted in your another query. The same mock class am posting again. If you aleady created then don't create the below class in your org otherwise you have to create it.
Please try the below test class:
Thanks,
Maharajan.C
All Answers
You can take reference from this below code.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks in advance
System.AuraHandledException: Script-thrown exception
Try this test class:-
If you want to cover catch block then you are getting this error.
Thanks
can u please solve this issue
You can use the try catch in test class to avoid this error System.AuraHandledException: Script-thrown exception
Try the below test class:
Thanks,
Maharajan.C
the catch exception is not covering still and also there is one more line return code also didint cover
could u please tell me solution for this
thanks in advance
Before use the below test class you need the mock class i have already posted in your another query. The same mock class am posting again. If you aleady created then don't create the below class in your org otherwise you have to create it.
Please try the below test class:
Thanks,
Maharajan.C