You need to sign in to do that
Don't have an account?
Zen Newman 16
Test Class Producting Zero Code Coverage
Hello, I have a fairly simple apex class that seems to working correctly to remove the html from a rich text field and populate a plain text field with the content. The test class, however, is producing zero code coverage and I'm not sure why. I appreciate any help on where I'm going wrong.
The main class:
The main class:
public class HTMLStripper { @InvocableMethod(label = 'HTML Stripper' description = 'Strips HTML from rich text fields and returns text value') public static void Stripper(List<Id> Ids){ List<Opportunity> lstOpp = new List<Opportunity>(); for(Opportunity opp : [SELECT Id, XDR_Notes__c FROM Opportunity WHERE Id IN : Ids]) { opp.XDR_Notes_Text__c = opp.XDR_Notes__c.replaceAll('<[/a-zAZ0-9&]*>',' '); lstOpp.add(opp); } if(lstOpp.size()>0){ update lstOpp; } } }And the Test Class:
@isTest public class HTMLStripperTest { static testMethod void HTMLRemoval() { //insert test lead Account a = new Account(Name = 'Test'); insert a; Opportunity o = new Opportunity(Name = 'Test', AccountId = a.Id, CloseDate = Date.today(), XDR_Notes__c = 'These are test lead notes'); insert o; //retrieve and test List<Id>lstOppId = new list<Id>{o.Id}; HTMLStripper.Stripper(lstOppId); Boolean result = o.XDR_Notes_Text__c.contains('>'); System.assertEquals(False, result); } }
Try following test class with 100% code coverage. let me know if it helps you and marking it as best.
Thank you
All Answers
Wanted to check if its throwing any error?
Thanks!
Try this test class.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks and Regards
Suraj Tripathi.
Try following test class with 100% code coverage. let me know if it helps you and marking it as best.
Thank you