An other great video, thank you guys! I have actually a question on Test.loadData / Static Resource: Is there any way to load User & UserLogin that way? I have a class setting a status field on frozen or locked users … but I can't set IsFrozen or IsPasswordLocked for a generated user in the test class. So after watching your video I have exported such a test-setup with locked and frozen users & their UserLogin and uploaded it as a static resource. But I'm running into errors without explanation. Have tried for days now, changed file format multiple times - other objects just load fine. I'm getting the 100% code coverage now by using live data … store two inactive user in the org, one frozen, one locked, … and I change logic to search for inactive users instead of active while test is running. Is there a better way to do this?
public with sharing class ApproveUpdate { @AuraEnabled public static void updatedrec(String ppaId) { try { // Perform the necessary operations to approve the claim record // Update the record status to "Approved" or perform any other required actions
// You can add additional logic or queries here if needed
// Example: Update the record PurchaserPlanAssn claimRecord = [SELECT Id, Status FROM PurchaserPlanAssn WHERE Id = :ppaId]; claimRecord.Status = 'Approved'; update claimRecord; } catch (Exception e) { throw new AuraHandledException('Error approving claim: ' + e.getMessage()); } }
@AuraEnabled public static void rejectClaimRecord(String ppaId) { try { // Perform the necessary operations to reject the claim record // Update the record status to "Rejected" or perform any other required actions
// You can add additional logic or queries here if needed
// Example: Update the record PurchaserPlanAssn claimRecord = [SELECT Id, Status FROM PurchaserPlanAssn WHERE Id = :ppaId]; claimRecord.Status = 'Rejected'; update claimRecord; } catch (Exception e) { throw new AuraHandledException('Error rejecting claim: ' + e.getMessage()); } } } the catch part is no gettting covered
Let’s say If I insert 200 Invoice records that each have 50 Line Items, It will exceed the 10000 limit for the number of rows. How would you test a scenario like this?
@SalesforceApexHours and #Amit. I am new to Salesforce and writing my first Rest API. I have created it and its working good. I need to create a Test class. I want to understand very basic thing. how could I let me test class know for which Apex code I am creating test class means how I can establish the connection. second I have multiple SOQL in my API. How I can establish the connection between my test class and Apex so It understand code coverage written for which SOQL
How to achive the code coverage for try catch block can you please give me any example if you have.it will help me to understand.thank you for the vedio
Sir please share the link of codes....the ApexHours site dont have the Codes only some theory parts...also those notes look incomplete for DAY 6 Lecture 1 and 2
When I assigned a particular permissions Set to user I want to update multi picklist value in Account while creating a new record. ???? Thanks advance!!
What record? Account created by the user with the permission set? You can query PermissionSetAssignment … so you could verify in a trigger if the context user has such assignment. developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_profile_permissions.htm developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_permissionsetassignment.htm
The video series is very helpful but this video and the 1st part of this video(Unit test) has been bit disappointing because the presenter had all the scripts ready and it becomes very difficult to understand what the existing code is and what he is trying to do. I suggest to have videos where the method class are written in the video and then test classes to test those classes. This will help people to understand what is being done from scratch.
wnice sir,But while u teach any concept on console then u scroll up n down its hard to understand what exactly u r doing beacuse i am non coder background.
An other great video, thank you guys! I have actually a question on Test.loadData / Static Resource:
Is there any way to load User & UserLogin that way? I have a class setting a status field on frozen or locked users … but I can't set IsFrozen or IsPasswordLocked for a generated user in the test class. So after watching your video I have exported such a test-setup with locked and frozen users & their UserLogin and uploaded it as a static resource. But I'm running into errors without explanation. Have tried for days now, changed file format multiple times - other objects just load fine. I'm getting the 100% code coverage now by using live data … store two inactive user in the org, one frozen, one locked, … and I change logic to search for inactive users instead of active while test is running. Is there a better way to do this?
No you can not insert UserLogin records.
public with sharing class ApproveUpdate {
@AuraEnabled
public static void updatedrec(String ppaId) {
try {
// Perform the necessary operations to approve the claim record
// Update the record status to "Approved" or perform any other required actions
// You can add additional logic or queries here if needed
// Example: Update the record
PurchaserPlanAssn claimRecord = [SELECT Id, Status FROM PurchaserPlanAssn WHERE Id = :ppaId];
claimRecord.Status = 'Approved';
update claimRecord;
} catch (Exception e) {
throw new AuraHandledException('Error approving claim: ' + e.getMessage());
}
}
@AuraEnabled
public static void rejectClaimRecord(String ppaId) {
try {
// Perform the necessary operations to reject the claim record
// Update the record status to "Rejected" or perform any other required actions
// You can add additional logic or queries here if needed
// Example: Update the record
PurchaserPlanAssn claimRecord = [SELECT Id, Status FROM PurchaserPlanAssn WHERE Id = :ppaId];
claimRecord.Status = 'Rejected';
update claimRecord;
} catch (Exception e) {
throw new AuraHandledException('Error rejecting claim: ' + e.getMessage());
}
}
} the catch part is no gettting covered
@Salesforce Apex Hours did you uploaded the code anywhere
We will try to post it soon. To much busy in my personal project work. Sorry about that.
@@apexhours did not uploaded code till now
This is so valuable! THANK YOU
Glad it was helpful!
@@apexhours just as ALL your videos. I cancelled Netflix, Discovery Plus, and even Disney subscribtios. All I watch is Apex Hours!
thanks alot, all videos are so clear and everything covered😃🙏🏻
You're welcome 😊
@@apexhours where should I get your classes code?
Let’s say If I insert 200 Invoice records that each have 50 Line Items, It will exceed the 10000 limit for the number of rows. How would you test a scenario like this?
Is there a specific reason why this session is covered in classic?
No such reason.
@salesforeceapexhours at 18:00,you have commented the casting ,yet the code is working fine, could you please tell me why did you cast it before
@SalesforceApexHours and #Amit. I am new to Salesforce and writing my first Rest API. I have created it and its working good. I need to create a Test class. I want to understand very basic thing. how could I let me test class know for which Apex code I am creating test class means how I can establish the connection. second I have multiple SOQL in my API. How I can establish the connection between my test class and Apex so It understand code coverage written for which SOQL
How to achive the code coverage for try catch block can you please give me any example if you have.it will help me to understand.thank you for the vedio
I will publish one blog post soon
Sir, from where I can get the source code of TestDataFactory Class?
Check ApexHours.com blog post
Sir please share the link of codes....the ApexHours site dont have the Codes only some theory parts...also those notes look incomplete for DAY 6 Lecture 1 and 2
When I assigned a particular permissions Set to user I want to update multi picklist value in Account while creating a new record. ????
Thanks advance!!
What record? Account created by the user with the permission set?
You can query PermissionSetAssignment … so you could verify in a trigger if the context user has such assignment.
developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_profile_permissions.htm
developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_permissionsetassignment.htm
Thanks for your help
The video series is very helpful but this video and the 1st part of this video(Unit test) has been bit disappointing because the presenter had all the scripts ready and it becomes very difficult to understand what the existing code is and what he is trying to do.
I suggest to have videos where the method class are written in the video and then test classes to test those classes. This will help people to understand what is being done from scratch.
thank you
You're welcome
What is the difference between data factory and test setup method?
salesforce.stackexchange.com/questions/233111/testsetup-vs-datafactory
@@apexhours Thanks
Thank you 😃
We are glad you liked it
Hi Amit, please help me create a static resource .
That part is there on recording
wnice sir,But while u teach any concept on console then u scroll up n down its hard to understand what exactly u r doing beacuse i am non coder background.
I can understand please pause the recording and see
can you please provide this assignment solution so that we can verify and improve our code
sure we will publish soon
Can someone plz provide the codes used in this video?
available on apex hours website
Amazing
Thank you! Cheers!
TestDataFactory Class is covered very fastly :(
Sorry about that, CHeck our post for more details www.apexhours.com/test-data-factory-in-salesforce/
Confusing
Sorry about that