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
1
vote
2answers
43 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
26 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 ...
-1
votes
0answers
32 views

Test Class for Aura variables

Can anyone help how to write the test class for below code public with Sharing class HBTGDM_TeamRecordHandler { @AuraEnabled public String fieldApiName ; @AuraEnabled public String ...
0
votes
2answers
37 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
31 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
18 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
41 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
39 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
26 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
24 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(){ //...
0
votes
1answer
21 views

How do I test a schedulable email sending?

I have a schedulable apex class for the email sending. I tested a schedule, but I can't to coverage sending logic. Is there a some way to test good and bad scenarios for it? My class: public class ...
1
vote
1answer
24 views

How to increase code coverage for apex class that contains only web callouts

I have an apex class which contains code only for web callouts and for this class I get coverage equivalent to 9% since actual web callouts are not a part of tests. So how am I supposed to increase ...
1
vote
1answer
35 views

Access Errors on FeedAttachment for Chatter Test Class

I am designing a test class for a Chatter component controller I did not design, and I am having issues creating test data. I have posted code below my issue description. I have removed most of the ...
1
vote
0answers
44 views

Need Test Classes for AutocreatedConfigSelfReg and AutocreatedDiscLoginHandler

I'm an admin and beginner developer who was setting up a community and thought that the login discovery page was a great user experience. Without due-diligence, I went ahead and selected the "create a ...
0
votes
0answers
29 views

How to do positive and Negative test for my test class for the below code [duplicate]

Need some advice on test classes, i dont know how to perform positive or negative tests on my test classes, Any advice would be highly appreciated below is my apex code for visualfore controller ...
0
votes
0answers
39 views

how do i design a test class for visualforce controller [duplicate]

I am new to the Salesforce Apex development, i know the basic knowledge of test classes, but i am not able to write the Test class for the below code please help, i somehow designed the test class ...
0
votes
0answers
35 views

Test Class Coverage: unable to associate Territory data with Group and AccountShare Objects

While writing test class, I am unable create the data that connects AccountShare, Group and Territory. Group and Territory are related by the field relatedID on Group which is read only. Has anybody ...
0
votes
2answers
34 views

I don't understand why my apex test isn't covering my trigger

I have a fairly simple use case -- if a field isn't set and it's updated by a member in a group, set the field with a difference between 2 times. The code looks like this: trigger FirstTouch on ...
0
votes
2answers
42 views

System.UnexpectedException: No more than one executeBatch can be called from within a test method

I have Added Limit to the Query and in Test Class @isTest(SeeAllData=false), if(!Test.isRunningTest()) -Every Solution I found Here .Even it's not working here .So please any one can Help? Apex Class ...
-1
votes
1answer
28 views

How to write Test class for the below [duplicate]

Apex class: public class ProdImedComAr { public class Respuesta { public Integer Codigo; public String Descripcion; public Long NroOperacion; public String ...
0
votes
1answer
14 views

TestMethod Doesn't Support Web Service Call Out Error For Trigger on delete

I have this trigger which deletes the Specific Objects records on delation of a record. I wrote a test class for this but since I am a toootal Noob, I was unable to manage to cover the whole thing and ...
-1
votes
2answers
56 views

Not able to improvie the code coverage for the class [duplicate]

I am not able to cover the lines for the below class which is in bold(four stars) and method called "getAccountMaxPriorityTerritory", can anyone help me how to do that please. Below is the method ...
-2
votes
1answer
41 views

Test Class for Contact Trigger is not working

I have this class below for the contact trigger. But, the Test class I wrote does not seem to work and I can't tell why it does not give any coverage. Trigger trigger contactTrigger on Contact (...
0
votes
2answers
58 views

My apex class code coverage is showing zero percentage on writing the test class

Apex class: public class GenRangoTarjeta_cls {// OJCB v 1.4 This class generates a range of cards concatenating the program code and country code public static void addRangoTarjeta (...
0
votes
0answers
14 views

Test class for multi HTTP callouts [duplicate]

I am making a callout to get access token as first callout and then making subsequent callout with the use of the access token. I am making use of StaticResourceCalloutMock for the test class but I am ...
0
votes
2answers
42 views

Apex trigger is showing 0% coverage, apex test is failing to update because contact name field is blank?

I wrote and confirmed working an ApexTrigger in a sandbox that looks like this: trigger LastTouched on FeedComment(after insert, after update){ List<Case> updates = new List<case>(); Set&...
-2
votes
1answer
36 views

Test class fails to call the method

can someone help me to find the cause why my test class doesnt cover the method that is called in the test class, as seen in my test class I create an instance to call the method from the class. But ...
0
votes
1answer
24 views

In test class can see all org users in list

I have written one query in test class for fetching users,as per my understanding query should return the user records created in test class only,but its giving all user from salesforce org.is that ...
1
vote
0answers
22 views

VS Code - Compare metadata in different orgs

The one thing that Eclipse IDE seemed to do well that I've not yet worked out in VS Code is comparing metadata in different orgs. Using VS Code, I know how to compare files which are in the same ...
0
votes
0answers
29 views

How do you create Resource Calendar in Apex for test class?

I need to have a Resource Calendar in Apex test class. I tried to do below in Test Class. List<Calendar> lc = new List<Calendar>(); for(Account acc :listAcc) Calendar c =...
0
votes
0answers
17 views

UI Theme Detection: Unit test code coverage

Since Winter '16, we have had the ability to add conditional logic to our Apex controllers and Visualforce pages based on the UI theme the user is currently working with (i.e. Classic vs. Lightning ...
1
vote
1answer
38 views

Deploy Commented Out Apex Class

In my Sandbox i have Generated some Apex Classes from WSDL (Synchronous and Asynchronous as default). I have commented out all the async code because i do not use it for the time being, but i don't ...
2
votes
4answers
81 views

Querying Apex Classes & Dependent Test Classes

Does anyone have any advice on how I can go about querying test classes and dependent test classes? Our Org is getting very large and finding the correct test classes for each class is becoming an ...
-1
votes
1answer
33 views

Code coverage for delete statement in batch class [duplicate]

How can I get increased coverage for this code? I get only 75% so far. Not able to cover the delete statement in the main class. Any help is greatly appreciated. Main Class: public void execute(...
-1
votes
1answer
43 views

Test method with not writable fields [closed]

Please help me test the method because I'm at a dead end. It does not return anything, but sets values ​​to two custom fields subject to several conditions. Half of the method is covered by tests, ...
0
votes
0answers
26 views

Test Class for Page Reference Method Help [duplicate]

I'm not sure where to get started with writing this test class. I'm a junior developer and when trying to test createCourse PageReference method I get either an insert or assert fails, or I get an ...
0
votes
3answers
35 views

Test cases in a list

I am trying to get code coverage for my list/loop but no matter what I try I am missing something and could use a hand if possible as I am trying to learn more about Apex. Trigger: trigger ...
1
vote
1answer
60 views

Everything worked fine in Production - but not enough code coverage in Salesforce

I've been tasked with updating our Salesforce. I'm a pretty experienced Salesforce Admin but I have to admit I know very little about apex code. Here's the situation. I've tested everything in ...
0
votes
2answers
36 views

Test Class for SOQL query failing

I have a apex class that is a SOQL query on a custom object. The query works just fine, however, when trying to deploy to production, deployment fails because it seems apex class has zero % code ...
0
votes
0answers
29 views

Attempting to get better code coverage on fairly simple trigger [duplicate]

I am new to working with Map objects in Apex and it has introduced a wrinkle to my test class process. I am only able to achieve 74% coverage and I absolutely cannot figure out why. This trigger is ...
0
votes
1answer
40 views

Error While updating the Owner of the Case to queue Id

Hi I am having the scenario where i need to update the owner of the case to a particular queue. but i am getting the error as below : System.DmlException: Update failed. First exception on row 0 ...
0
votes
1answer
25 views

Question Concerning making a Test class for a before update trigger that sends an email

I'm currently trying to make a test for an apex trigger that sends an email if a certain donation field has been changed(before this I tried using a workflow but for some reason it did not work). From ...
0
votes
2answers
73 views

mock test class and test class for 2 classes

I have 2 class A and B. A has code for Http Callout and from B we are calling A's class method which has callout code. So should we write mock test class for A only or do we have to write mock test ...
0
votes
1answer
46 views

Get ApexCodeCoverageAggregate resultes in CSV

I am using the belwo querying in Query Editor in Developer Console: SELECT ApexClassOrTrigger.Name, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate Enabling the Tooling API like ...
0
votes
0answers
14 views

Apex Code Coverage for if/else if test class [duplicate]

if (userList.size() > 0 ) { String profileName = userList[0].Profile.Name; if (profileName == 'CP_CorporateAdminUser' || profileName == CP_SystemConstants.CORPORATE_OPERATION) { ...
0
votes
2answers
29 views

Test Method Fail on Apex class with Meta Object

I am writing a simple api callout for Tsheets, and its working just fine, now when writing the test class, its failing on the line "object results = Meta.get('results')". The error is: System....
0
votes
0answers
15 views

How to write the Test class for the Apex Trigger [duplicate]

trigger populateContactEmail on Case (before insert , before update){ Set<Id> setConIds = new Set<Id>(); for(Case obj : trigger.new){ if(obj.Secondary_Contact__c != null) ...
0
votes
1answer
37 views

My test class code coverage is 100 percent but it is giving following error in run

For report event my test class code coverage is 100% but it is giving following error System.UnexpectedException: common.exception.SfdcSqlException: We encountered an unexpected error. Contact ...
0
votes
1answer
33 views

Test class not working for more than two or three methods in same class it fails for other two methods only one method covers

public with sharing class TransactionsalSecurity { @AuraEnabled public static List<ReportEvent> TransactionalSecurityToday() { return [SELECT Name, QueriedEntities, Format, ...
0
votes
0answers
23 views

Need Help for Apex Test Class [duplicate]

i have a problem with test code coverage of my trigger: that's the code: public class OpportunityLineItemTriggerHandler{ public static Boolean isTriggerFire = true; public static void sync(Set<Id&...