Skip to main content TDX, the developer conference for the AI agent era is happening now. Watch live on Salesforce+ for exclusive digital content, a revolutionary keynote, and more.

The 'LeadProcessor' class did not achieve 100% code coverage via your test methods. Make sure that you chose 'Run All' tests in the Developer Console at least once before attempting to verify this challenge.

 

Facing the above error, have tried multiple codes

 

#Trailhead Challenges

17 respuestas
  1. 2 jul 2024, 18:19

    Hi @Ankit Bisht,

     

    Thanks for provided the org access. The test is failed due to an active validation rule on Lead object. I have deactivated it and ran the Lead Processor test again and test coverage 100% completed and the challenge check is working as expected.

     

    Hi , Thanks for provided the org access. The test is failed due to an active validation rule on Lead object.

     

    May I request you to please check the challenge and hopefully it works now.

     

    Please feel free to mark my answer as best answer so that can be helpful for other Trailblazers over the community.

     

    Best Regards,

    Ravindra

  2. 2 jul 2024, 13:02

    Hi @Ankit Bisht,

    I'm a member of the Trailblazer Help team. This issue needs further review and we may need access to your playground. We will reach out to you via email to connect further. Thank you!

     

    Best Regards,

    Ravindra

     

    ++CreateTrailheadCase

  3. 28 jun 2024, 17:09

    Hello @Eric Burté,

     

    Pls find the code below,

     

    3.1 LeadProcessor

    *****************

    public class LeadProcessor implements Database.Batchable<sObject> {

       

         public Database.QueryLocator start(Database.BatchableContext bc) {

            // collect the batches of records or objects to be passed to execute

              return Database.getQueryLocator([Select LeadSource From Lead ]);

        }

        public void execute(Database.BatchableContext bc, List<Lead> leads){

             // process each batch of records

                for (Lead Lead : leads) {

                    lead.LeadSource = 'Dreamforce';

                }

            update leads;

        }   

        public void finish(Database.BatchableContext bc){

          }

     

    }

     

    3.2 LeadProcessorTest

    ************************

    @isTest

    public class LeadProcessorTest {

       

            @testSetup

        static void setup() {

            List<Lead> leads = new List<Lead>();

            for(Integer counter=0 ;counter <200;counter++){

                Lead lead = new Lead();

                lead.FirstName ='FirstName';

                lead.LastName ='LastName'+counter;

                lead.Company ='demo'+counter;

                leads.add(lead);

            }        

            insert leads;

        }

        

        @isTest static void test() {

            Test.startTest();

            LeadProcessor leadProcessor = new LeadProcessor();

            Id batchId = Database.executeBatch(leadProcessor);

            Test.stopTest();   

        }

     

    }

  4. Eric Burté (DEVOTEAM) Forum Ambassador
    29 nov 2024, 8:25

    Hello @Ananth Muralidharan just run your test from vscode / from the dev console. In the terminal (for VSCode) ou in the test panel (of the dev console) you will get a summary of the run tests, telling you for each method if the assertions went well, or if something unexpected happened. Eric

  5. Eric Burté (DEVOTEAM) Forum Ambassador
    27 nov 2024, 22:16

    Hello @Ananth Muralidharan this test code coverage issue was not linked to the test class code, but to an extra validation rule (due to the fact it was done on a already used playground, and not on a brand new one) that was failing the test class, and was thus interfering with the challenge. Eric

  6. 3 jul 2024, 9:13

    Hello @Eric Burté,

     

    Not entirely sure what went wrong, but it seems like there was a validation rule issue. Good news though, it's all sorted now! I can also breeze through the other units in the module, no problem.

  7. Eric Burté (DEVOTEAM) Forum Ambassador
    3 jul 2024, 9:07

    Hello @Ravindra Babu Sikhakolli, hello @Ankit Bisht, so that was not about the coverage, but a failing test class method. Eric

  8. Eric Burté (DEVOTEAM) Forum Ambassador
    28 jun 2024, 9:11

    @Ankit Bisht for information, after running all your tests, you can see the covered / not covered code, from with the Dev Console, just by navigating to the test tab of the Dev Console, and then selecting the class on which to focus for your analysis

    That would give you something like (sample)for information, after running all your tests, you can see the covered / not covered code, from with the Dev Console, just by navigating to the test tab of the Dev Console, and then selecting the clasEric

0/9000