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
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.
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
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
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();
}
}
Eric Burté (DEVOTEAM) Forum Ambassador
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
Hi @Eric Burté, How do I find which class was failing? Or is it easier to provision a new playground and solve this?
Eric Burté (DEVOTEAM) Forum Ambassador
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
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.
Eric Burté (DEVOTEAM) Forum Ambassador
Hello @Ravindra Babu Sikhakolli, hello @Ankit Bisht, so that was not about the coverage, but a failing test class method. Eric
Eric Burté (DEVOTEAM) Forum Ambassador
@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)
Eric