You need to sign in to do that
Don't have an account?
Giussep Estrada
Help with my First Test Class
Hello guys
First post
I'm a newbie in Salesforce trying to understand how i can write test classes
I need to write a test class of the following class:
I just want to learn how i can do it
First post
I'm a newbie in Salesforce trying to understand how i can write test classes
I need to write a test class of the following class:
public class RelatedListEditController { @AuraEnabled( cacheable=true ) public static List < sObject > fetchRecords( String listValues ) { List < String > strList = listValues.split( ',' ); if ( strList.size() >= 3 ) { String recordId = strList.get( 0 ); String objectName = strList.get( 1 ); String parentFieldAPIName = strList.get( 2 ); String strSOQL = 'SELECT Id FROM ' + objectName + ' WHERE ' + parentFieldAPIName + ' = \'' + recordId + '\'' + ' WITH ' + 'SECURITY_ENFORCED'; strSOQL += ' LIMIT 20'; return Database.query( strSOQL ); } else return null; } }Any help would be appreciated
I just want to learn how i can do it
I would suggest you check out the section on writing unit tests in the Apex developer guide.
Apex Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing.htm)
For the code you published, here is a sample test class to get you started. I hope this helps.
All Answers
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/apps_packaging_tests.htm
If it helps please like and mark as correct, it may help others with the same issue
I would suggest you check out the section on writing unit tests in the Apex developer guide.
Apex Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing.htm)
For the code you published, here is a sample test class to get you started. I hope this helps.