New answers tagged

1

Use apex mocks to achieve the goal. Apex mock is used to get a response from the callout you need. So when you are doing a callout HttpRequest req = new HttpRequest(); req.setEndpoint('http://example.com/example/test'); req.setMethod('GET'); Http h = new Http(); HttpResponse res = h.send(req); the last line will basically return the result you want. To ...


0

Unit Test is Providing 0% Coverage for Apex Trigger trigger Splittrigger_newclass on Indexing__c (before delete,after insert) { list lstvoyage=new list(); list q = new list(); list p = new list(); //To store parent ids list<id> IndIds=new list<id>(); for(Indexing__c Ind:trigger.old) { IndIds.add(Ind.id); system.debug('inids&...


0

There is a catch here. If a FeedItem record is created with Type = 'ContentPost', following are also required fields: - ContentFileName - ContentData (Blob Data) On top of that these fields are deprecated for API version 35.0 above. So, try changing the API version to 35.0 or below and then try creating a FeedItem record with above data in the test class, ...


0

The problem was in Contact as i was causing error for some other reasons when i removed contact part from test class i got the answer Test Class @isTest public class TestChapterRollupBatch { static testMethod void testMethod1() { List lstAccount= new List(); for(Integer i=0 ;i<10;i++) { ...


0

Issue solved with lots of help from @Derek F above Trigger: trigger FirstTouch on FeedComment (after insert, after update){ List<Case> updates = new List<case>(); List<FeedItem> feedItemList = new List<FeedItem>(); List<Id> parentIds = new List<id>(); Map<Id, User> userMap = new Map<Id, User>([SELECT Id FROM ...


3

Usually, it helps (with questions of this nature) to provide some indication as to what lines aren't being covered. With such a short trigger, and 53% coverage, I feel safe making an educated guess that your coverage stops after your main query: for(Case c : [Select Id from Case where Id IN (Select ParentId FROM FeedItem WHERE Id IN: feedItemList)]){ That'...


2

This error actually means that the execute method should be called only ones. In order to achieve this, you have to be sure that: 1) Your query in the start method returns all records in the test context that are available for the batch. In your example, it should be 1. So, check that only one account is present as you have LIMIT 1. 2) Remove (SeeAllData=...


2

You just need to create an instance of the inner class and it should cover the class that you have mentioned in the question. So the below test class should give you 100% code coverage @isTest public class ProdImedComAr_Test { @isTest public static void unitTest(){ ProdImedComAr.Respuesta req = new ProdImedComAr.Respuesta(); } } But ...


0

If you run the test class in the developer console, then open the tested class in the developer console, you can click on the "Code Coverage" button at the top to see which lines of code are covered and which ones are not. Have a look at which lines are not covered, and create test methods to cover them (and obviously, assert that the behaviour/output of ...


0

The code that you showed doesn't have any callouts, so I assume that either your Account or Customer Todo trigger have a web service callout in it. In order to write a test class for a class that has a callout, you will need to implement a Mock class. You can read more about it here.


0

I have written the below code still not working @isTest public class TerrAssignDefaultFiltertest{ @isTest static void unitTest() { Id opportunityId = [Select Id From Opportunity].Id; set<id> accountidset = new set <id>(); for(account a:[Select Id From account limit 10]) { accountidset.add(a.id); ...


0

I think you should pass account id to the opportunity you inserted in the testSetup method in your test class. Set<Id> accountIds is null in getOpportunityTerritory2Assignments method because you didn't pass the accountId in the testSetup method. You can pass accountId = acc.Id in the opportunity while insertng. @testSetup static void setup()...


Top 50 recent answers are included