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.
Fehler

Da ist etwas schief gegangen. Versuchen Sie es noch einmal.

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.

 @Ankit Bisht and @Eric Burté - seems like you guys fixed this issue few months back. Could you please help?

#Trailhead Challenges

5 Antworten
  1. Divya Chauhan (Kcloud Technologies) Forum Ambassador
    28. Nov. 2024, 05:22

    Hello@Ananth Muralidharan,

    Please try,

    make sure you have saved the code

    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){

    }

    }

    @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();

    }

    }

0/9000