3

You have a bug that should be causing at least one of your unit test methods to fail, not just to miss code coverage. List<Account> acc=[Select Id,OwnerId from Account Where Id=:c.Id]; cs.AccountId=acc[0].id; No Account will ever have an Id equal to c.Id (you meant c.AccountId). This should result in an exception being thrown when you access the first ...


2

This Canonical QA nicely covers most questions related to bulkifying queries. There's another wrinkle here, though, because you are working with Task, which has a polymorphic What relationship. You do not need to write multiple queries for different objects, because you can query for Name through a polymorphic relationship. SELECT What.Name, What.Type FROM ...


2

Passing the parameter as null is possible to complete the test successfully, and for @InvocableMethod it is only to perform the normal test. @isTest public class CallFraudPreventionEventLogsTest { static TestMethod void TestOne(){ Test.startTest(); new CallFraudPreventionEventLogs().execute(null); Test....


2

Based on your other question here: can't seem to get proper code coverage. any ideas? your method returns a string. Test.startTest(); String returnData = LifeLargeCaseReviewCtrl.createLLCRCase(caseObj, policyList, propObj, cdl.Id); Test.stopTest(); System.assertEquals('Success', returnData, 'Case was not able to be created.');


2

From your screenshot, looks like the fourth argument to the LifeLargeCaseReviewCtrl.createLLCRCase method should be a ContentDocumentid. Instead you are passing in ContentDocumentLink Id. Change LifeLargeCaseReviewCtrl.createLLCRCase(caseObj, policyList, propObj, cdl.Id); to LifeLargeCaseReviewCtrl.createLLCRCase(caseObj, policyList, propObj, documents[0].Id)...


2

You need to instantiate the controller object first ShouldShowMedSection ctrl = new ShouldShowMedSection( new ApexPages.StandardController( new Intake__c(Client_Name_First_and_Last_Initial__c = 'Test Client A', Personal_Care__c = 'xxxMedicationxxx'))); System.assertEquals(true,ctrl. getShouldShowMedSection(),'sb valid'); ...


2

You can't override the return value of URL.getSalesforceBaseUrl() in a test class. There's two possible approaches here. One is to factor out the code that calls that method into a separate code unit so that you can utilize dependency injection to control its return value. But that seems like overkill here. There's a much simpler option: refactor your code ...


1

I have not worked with those objects, but note that not all infrastructure related data can be modified. For the cases where they cannot, you either have to construct the test to work with no records, or if the objects are in the group that are visible make assumptions about the data. Or accept that a unit test can't be created. Note that this: UserAppInfo ...


1

Remove the try-catch block. It is not possible to have an exception here. Generally speaking, if you're having problems trying to cover a try-catch block, it is either untestable, or unnecessary. It's important to learn when exceptions can occur in order to catch them effectively. Also see Pokemon Catch - Generic Exception Handling In Apex and Test Code ...


1

There are a couple of ways you can test this when you have more than one apex callout. Adopt any one of these approaches based on your preference. 1. Using MultiStaticResourceCalloutMock and Static Resources. In this approach, you put mock responses in the static resource that is a text file with mock data in JSON format. An example of this as below and can ...


1

In your test class, you are trying to query a case record where you look up against a contact Id, that will never yield a result. Instead: List<Case> cs = [SELECT Id, ContactId, AccountId FROM Case WHERE Id = :cont.Id]; Change it to: List<Case> cs = [SELECT Id, ContactId, AccountId FROM Case WHERE ContactId = :cont.Id];


1

I'm not sure that inserting a ContentVersion implicitly creates a ContentDocument that has an id that can be used in a cdl's ContentDocumentId field. Try creating one explicitly. Also, to see what type of object that id is actually of, try calling documents[0].Id.getSobjectType().getDescribe().getName()


1

You would want to use the Aggregate-Query-Update pattern. Here's one possible revision that should do what you want: trigger GetObjLabel on Task (before insert, before update) { Map<Id, sObject> whatIds = new Map<Id, sObject>(); Set<sObjectType> types = new Set<sObjectType>(); for(Task record: Trigger.new) { ...


Only top voted, non community-wiki answers of a minimum length are eligible