Questions tagged [code-coverage]

Questions about specific lines of code that need coverage or platform bugs. 75% of your Apex code must be covered by test classes. This tag is not intended for use when code coverage is simply lacking, but for scenarios where because of a particular configuration or system issue code coverage is challenging.

Filter by
Sorted by
Tagged with
0
votes
1answer
14 views

What is wrong with this test class? It is not covering, any suggestions? Thanks,

@isTest public class PropRentTotalSumTEST { @isTest static void testFeeCalculation() { Property__c prop = new Property__c(); prop.Name = 'Test'; prop.Monthly_Rate__c = ...
0
votes
0answers
24 views

Test.SetMock() is not working (for WebService callout)

There are two integration classes. One gets a response from the other. I am not able to call the Mock class from Test class hence I am not able to get mock response and I am not able to increase the ...
0
votes
1answer
20 views

How to test a scheduler class scheduling itself and calling a batch. Check out the code

I have a batch class which is called by an scheduler class which is scheduling itself. I have written a test class which has two methods: One tests the batch and the other the scheduler.Overall the ...
0
votes
0answers
24 views

Test class for the code below [duplicate]

// Hi Community, I need a help to write a test class for this code, can someone help me with? public with sharing class PropRentTotalSum { public static void RentTotal(List<Fee__c> ...
0
votes
1answer
12 views

Test for Generated Class From WSDL

Should I write unit test for those apex classes generated from wsdl when deploying to production?
-1
votes
1answer
37 views

How to write test for this trigger [duplicate]

Want to write Test case and unit test for this trigger trigger Autoleadconversion on Lead (after insert, after update) { for (Lead lead : Trigger.new) { if (lead.isConverted ==...
0
votes
1answer
25 views

Test Class for Apex Batch Job generating Invoices covers only 38%

Please help me to finish my Test Class for the following Batch Job generating Invoice creation. Apex Batch Job global class InvoiceGenerateBatchJob implements Database.Batchable<SObject> { ...
0
votes
1answer
20 views

How to avoid in unittest Error: Invalid type: ZuoraObject.ConvertToZuoraInvoiceDatas

I have a following class with method public virtual class ZuoraObject { .. public static List<InvoiceData> ConvertToZuoraInvoiceDatas(List<Zuora.zObject> zInvoiceDatas) { if (...
1
vote
0answers
21 views

How to get code coverage with logic based on screen flow variables?

I am trying to get code coverage to deploy a class that depends on variables set in a screen flow. I've read various articles saying it's not possible to get coverage for screen flows. Is this ...
-1
votes
0answers
11 views

Need help with Salesforce Test Class [duplicate]

This is my Apex controller public class QuoteController { //Get Opportunity_Quotes__c Records @AuraEnabled public static List<Opportunity_Quotes__c> getQuote(Id id,String ...
0
votes
0answers
36 views

Unit Test - No Code Coverage with Wrapper Class

Having issues getting any code coverage, no lines have been covered yet i am returning the data to the test method that I want and the System Assert is running as anticipated Class to Be Tested ...
1
vote
1answer
39 views

Best tool for seeing highlighted covered Apex Code while writing test class

Currently I do most of my development in VScode using sfdx. For writing test classes, I need to see which lines are covered in Apex classes I write. In DX, running commands (see below) to get ...
2
votes
1answer
35 views

Test Class for ContentDocumentLink causing Internal Salesforce Error

I have a test class that is inserting a ContentDocumentLink between a ContentNote (SNOTE) and a custom object. Everytime I try the insert it causes an Internal Salesforce Error. I have absolutely ...
0
votes
0answers
20 views

Test class for below wrapper class in salesforce [duplicate]

public class SortingDates { Public List<SortingDatesWrapper> cList {get;set;} public SortingDates() { cList = new List<SortingDatesWrapper>(); List<...
0
votes
1answer
29 views

How to cover the catch block for after insert Trigger?

When you create a Barrel, a Filling is also created. Is there any chance to make a fake error in unit test between Barrel and Filling to crush the upsert process and cover the catch block? Helper: ...
0
votes
1answer
12 views

Test Coverage discrepancies for QuickAction.QuickActionDefaultsHandler

Test Class runs successfully and test coverage is 100% but fails during deployment saying "Your Code Coverage is 70%". @isTest public class DefaultSignatureForEmail_Test { static { ...
-1
votes
2answers
40 views

Can't cover DMLException with my test

I'm trying to cover my Exceptionm But I don't know. how to do this. When I try to insert a record without Required fields, I get the System.DmlException: Insert failed. First exception on row 0; first ...
1
vote
1answer
30 views

Test coverage for wrapper class which takes user input

In wrapper class, there is a boolean variable named isSelected which I need to make true to increase coverage of a method. The constructor of the class always initializes the value to false. I am not ...
2
votes
0answers
63 views

How to write an Apex test for a Process Builder's scheduled actions?

I'm creating test coverage code for an autolaunched flow to push to production. Using the Tooling API in developer console, I can see that I almost have 50% coverage 4/11 elements covered (as seen ...
0
votes
0answers
29 views

How to test inner class in trigger?

I have the following legacy code that I have to test: trigger reportingTargetsChanged on Reporting_Targets__c (after insert, after update) List<Reporting_Targets__c> reportingDatas = [...
0
votes
2answers
25 views

How to set the ActivatedDate and ActivatedById fields on the Order object in an Apex test class?

I am trying to cover the following condition in my Apex test class and the ActivatedByID and ActivatedDate are always being set as null. In the test class, I created an order, set it's status as '...
0
votes
0answers
24 views

Test Class Passing but Code Coverage is 0% [duplicate]

I am trying to create some records in the Account object which needs three fields to be populated: Name, Phone and E-mail. I am trying to achieve it using custom controller. I have created a VF Page ...
0
votes
1answer
33 views

test class for wrapper class in apex

public with sharing class ResponseWrapper{ public String Id; public String Time; public String lobType; public String businessContextId; public Information[] document; public ...
0
votes
1answer
56 views

Test class creates data, but the code I'm testing can't query it during the test run

I am writing a test for some code I wrote for a trigger. I create all of the data in the test, and have SeeAllData = false. The test class invokes the trigger, but a query in the trigger helper code ...
0
votes
0answers
45 views

Apex Test Class for SOQL [duplicate]

I'm having trouble providing code coverage for my Apex Class. Apex Class public class CSMetricsDashboardController { public CS_Metrics_Dashboard__c dashboard {get;set;} public ...
1
vote
1answer
35 views

Can i improve code coverage for loop in batch apex

Firstly I wanna protect my organization code coverage, My scenario is as follows; I wrote 1 batch apex process, for calculate cycleTime to every products, am getting %80 covarage with this code but ...
-1
votes
1answer
36 views

Test class is giving only 3% coverage of apex class [duplicate]

i have a class for which have written test class as well, included all conditions in test, which are there in class. But not sure why it is giving me coverage only 3%. have done many changes in it ...
2
votes
1answer
41 views

ApexTestResultLimits in Tooling API work for both synchronous and asynchronous runs?

The documentation at ApexTestResultLimits states that: The ApexTestResultLimits object is populated for each test method execution, and it captures the limits used between the Test.startTest() and ...
0
votes
0answers
31 views

System.JSON.deserialize not covering Parser class [duplicate]

I am deserializing a response with a class. In my test class i am passing dummy JSON String, but its covering all the lines in class. public class CustomerAccount { public class OrgDetails{ ...
0
votes
1answer
27 views

Regarding code coverage by multiple test classes

I am having multiple test classes for one apex class . If I run one test class it gives overall coverage for the apex class as 50% . By running other test class it drops down to 30 %. My basic doubt ...
0
votes
0answers
29 views

Trigger code coverage and record type

here's my code on the trigger and getting 2 issues. I am trying to create new Integration opportunity upon an Opportunity stage becomes 'Closed won' It's not changing the newly created Integration ...
0
votes
2answers
51 views

Problem with unit test and Custom Setting with @AuraEnabled

There was a problem writing a unit test. I tried to use the usual HttpRequest and Mosk, but they do not work with Costom Setting. Here is my controller and test, which does not completely cover the ...
0
votes
1answer
26 views

Value of field not getting updated in test class

trigger OpportunityTrigger on Opportunity (before insert) { for(Opportunity thisOpportunity : Trigger.New) { thisOpportunity.New_Value__c ='Actual Trigger Value'; } } This is my test ...
0
votes
1answer
29 views

Custom APEX HTTP POST class fails to pass code coverage [duplicate]

I wrote a simple APEX class that should send some data as a HTTP POST request to some webhook. It receives some parameters as a collection and is called from a flow. global class send_sms_to_webhook {...
0
votes
1answer
35 views

Trigger and TriggerHandler not covered by Test

I'm faing an issue trying to test a trigger and its trigger handler. The test insert record of the SObject corresponding to the trigger and it's handler but the they are not executed thus not covered. ...
0
votes
0answers
26 views

1/2 Test Methods Passed: first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

I have two test methods doing similar things, but one fails. Test Code is: @IsTest private class CaseDocumentListControllerTest { static testMethod void testGetContentDocuments() { ...
0
votes
1answer
25 views

Need help with Test coverage of batch apex error- System.InvalidParameterValueException:

I am trying to write a test class for the batch apex class, but i am getting an wierd error(System.InvalidParameterValueException: Provide the ID of a test-context sObject as the first parameter for ...
0
votes
1answer
23 views

Trying to deploy Automatic Attachment Cloning trigger between two custom objects [duplicate]

I try to deploy a trigger from sandbox tp production but my test class does not fill the code coverage of the trigger it is supposed to check. I am new to Apex (or Java) & don't know what is ...
0
votes
2answers
43 views

Test Class with No Input [closed]

This is my Controller: And this is my test class: and this is the error I'm receiving:
0
votes
0answers
18 views

Assistance with Test Class [duplicate]

I could get a sample class to automatically deactivate inactive users in Salesforce and did some changes to it: public class DeactivateInactiveUsers implements Schedulable { public void ...
0
votes
1answer
24 views

Apex Test Class for custom Datatype

I'm literally pulling my hair out... I have this Apex Class: public with sharing class ProviderAPI_Datatype { Public Class Customer { @AuraEnabled Public String CustomerName {get;...
1
vote
2answers
65 views

How to correctly construct a TestClass for an API Rest Callout | Getting the error “Method does not exist or incorrect signature”

Apex Class for REST Callout public with sharing class FindAnApprenticeship { public class Payload{ @invocableVariable(label='Find An Apprenticeship URL') public String ...
0
votes
0answers
28 views

Test class coverage only 30% stucked to pass controller [duplicate]

Apex class public class InspectionControllerExtension { public List<Inspection_Checks__c> Inspection_Checks {get;set;} public String currentRecordId {get;set;} //transient ...
0
votes
2answers
38 views

problem with trigger validation test in productive environment

I generated a trigger for one of my clients and I created the test class with a 100% validation of coverage, however, after modifying the code the following error still appears and I can not think of ...
0
votes
2answers
32 views

How to write a test list of the Trigger [duplicate]

I am very new at the development. I finish writing the Trigger but have no idea with the test code. I trying to write the test code but get 0% of code coverage. Here is my Trigger and test code. ...
0
votes
1answer
25 views

Knowledge article created in test class not returning in SOSL

I have a class which is used in Chat bot to return the article links to the customer according to the product he selects. This is the class that I have created : public class ...
0
votes
1answer
43 views

Code Coverage=0%

my developer createed the following trigger and Apex Test Class. For some reason, the coverage is 0%. I need to deploy it ASAP and he already left for the rest of the week. any help is highly ...
0
votes
2answers
116 views

do not run process builder from test class execution [duplicate]

we have one test class on execution process builder is getting fired. is there any way where I can avoid to run process builder while running test class.
-2
votes
1answer
29 views

System.DmlException: Update failed. when running test class

I am creating a test class and receive the following error when running the test. System.DmlException: Update failed. First exception on row 0 with id 0012o00002WUpPFAA1; first error: ...
1
vote
1answer
32 views

Setup method System.QueryException: List has no rows for assignment to SObject

Can someone help me out with my test class, Im getting an error where it says list has no rows? @isTest private class dailyUpdatesMortgageTest{ @testSetup static void setup(){ //...

1
2 3 4 5
19