New answers tagged

2

You don't write a unit test for classes like this. Only executable, non-debug, non-test, non-comment lines of code count for code coverage, so this class automatically has 100% code coverage.


3

You need to query the PersonContactId field and use that instead. 001 is always an Account Id, while 003 is always a Contact Id. return accountList; Should be more like: return [SELECT FirstName, LastName, PersonContactId, PersonEmail FROM Account WHERE Id = :accountList]; Then you can: ContactId= accounts[i].PersonContactId,


1

Instead of using return value, you can directly use the RestContext response. As per the documentation here below is true for responseBody property of RestResponse class The response is either the serialized form of the method return value or it's the value of the responseBody property based on the following rules: If the method returns void, then Apex ...


2

When you bypass trigger logic, you need to bookend your disablement. Typical flow is as below: @IsTest static void myTest() { // disable trigger // insert data // enable trigger Test.startTest(); // update data Test.stopTest(); // assert against behavior }


0

// This test class covered 100% code for Delete_Content_Document__e trigger @isTest public class DeleteContentDocumentTriggerTest { @testSetup static void createTestData() { Global_Settings__c globalSettings = new Global_Settings__c(Name = 'Default', Disable_Triggers__c = true); if(globalSettings != null) insert globalSettings; ...


1

That object is a platform event. You can view that in Setup > Platform Events. The trigger is written on insert and it is likely not getting covered because of the commented line in the test class //EventBus.publish(dc); which will invoke this trigger. You should uncomment this line an run the test. Make sure to pupulate details like ...


1

From my perspective a unit test tests an Apex class/method in isolation. The flow is external to the Apex and isn't something to be tested together with the Apex code in a unit test. Sure, you might want to do that in an integration test, but this isn't needed to increase code coverage. There are various ways to deal with this sort of scenario. My ...


Top 50 recent answers are included