Write effective Unit tests/ test Classes | DAY 6 PART 2

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024

Комментарии • 52

  • @heikokraemer2735
    @heikokraemer2735 4 года назад +2

    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?

    • @apexhours
      @apexhours  4 года назад

      No you can not insert UserLogin records.

    • @priyankasingh8453
      @priyankasingh8453 Год назад

      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

  • @lbbhajandhuns
    @lbbhajandhuns 3 года назад +2

    @Salesforce Apex Hours did you uploaded the code anywhere

    • @apexhours
      @apexhours  3 года назад

      We will try to post it soon. To much busy in my personal project work. Sorry about that.

    • @ponnaakhil3574
      @ponnaakhil3574 2 года назад

      @@apexhours did not uploaded code till now

  • @AnnaSzabo
    @AnnaSzabo Год назад +1

    This is so valuable! THANK YOU

    • @apexhours
      @apexhours  Год назад +1

      Glad it was helpful!

    • @AnnaSzabo
      @AnnaSzabo Год назад

      @@apexhours just as ALL your videos. I cancelled Netflix, Discovery Plus, and even Disney subscribtios. All I watch is Apex Hours!

  • @sharma93anks
    @sharma93anks 3 года назад +2

    thanks alot, all videos are so clear and everything covered😃🙏🏻

    • @apexhours
      @apexhours  3 года назад

      You're welcome 😊

    • @Manikantagadde
      @Manikantagadde 3 года назад

      @@apexhours where should I get your classes code?

  • @jagrelot
    @jagrelot 4 года назад +1

    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?

  • @ameensams
    @ameensams 3 года назад +1

    Is there a specific reason why this session is covered in classic?

  • @mrbeast3473
    @mrbeast3473 3 года назад

    @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

  • @enlightenedviaenvisions
    @enlightenedviaenvisions 3 года назад

    @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

  • @karanammaheedhar3595
    @karanammaheedhar3595 2 года назад +1

    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

    • @apexhours
      @apexhours  2 года назад +1

      I will publish one blog post soon

  • @chhavisinghal9042
    @chhavisinghal9042 4 года назад +1

    Sir, from where I can get the source code of TestDataFactory Class?

    • @apexhours
      @apexhours  4 года назад

      Check ApexHours.com blog post

  • @adarshsingh-lb3ws
    @adarshsingh-lb3ws Год назад

    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

  • @vickyvijay1515
    @vickyvijay1515 4 года назад +1

    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!!

    • @heikokraemer2735
      @heikokraemer2735 4 года назад

      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

    • @apexhours
      @apexhours  4 года назад +1

      Thanks for your help

  • @sanjayagrawal7288
    @sanjayagrawal7288 2 года назад

    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.

  • @atozknowledgehub4488
    @atozknowledgehub4488 3 года назад +1

    thank you

  • @RVAraghav
    @RVAraghav 4 года назад

    What is the difference between data factory and test setup method?

    • @apexhours
      @apexhours  4 года назад

      salesforce.stackexchange.com/questions/233111/testsetup-vs-datafactory

    • @RVAraghav
      @RVAraghav 4 года назад

      @@apexhours Thanks

  • @viewer1353
    @viewer1353 4 года назад +1

    Thank you 😃

    • @apexhours
      @apexhours  4 года назад +2

      We are glad you liked it

  • @sachinpradhan7519
    @sachinpradhan7519 4 года назад +1

    Hi Amit, please help me create a static resource .

    • @apexhours
      @apexhours  4 года назад

      That part is there on recording

  • @prashantpatil6073
    @prashantpatil6073 4 года назад +1

    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.

    • @apexhours
      @apexhours  4 года назад

      I can understand please pause the recording and see

  • @ashishsinghrajput888
    @ashishsinghrajput888 3 года назад +1

    can you please provide this assignment solution so that we can verify and improve our code

    • @apexhours
      @apexhours  3 года назад

      sure we will publish soon

  • @maheshd4566
    @maheshd4566 2 года назад +1

    Can someone plz provide the codes used in this video?

    • @apexhours
      @apexhours  2 года назад

      available on apex hours website

  • @guptagopal
    @guptagopal 4 года назад

    Amazing

    • @apexhours
      @apexhours  4 года назад +1

      Thank you! Cheers!

  • @deepakgidwani9003
    @deepakgidwani9003 Год назад

    TestDataFactory Class is covered very fastly :(

    • @apexhours
      @apexhours  Год назад +1

      Sorry about that, CHeck our post for more details www.apexhours.com/test-data-factory-in-salesforce/

  • @maheshd4566
    @maheshd4566 2 года назад

    Confusing