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
1answer
19 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
27 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 ...
0
votes
0answers
33 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
28 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
32 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 ...
-1
votes
0answers
24 views

Test Class coverage help [duplicate]

Below is the class I am trying to cover, How can I cover @AuraEnabled annotation? If anyone has any idea please help with this test class. public Without Sharing class ScrambleUserInfoService{ ...
-1
votes
0answers
29 views

how to cover the below red lines for the test class?

my test class method for the above: static void testEmailUtility() { Test.StartTest(); BatchUtilClass.futureMethod(); Test.stopTest(); }
0
votes
2answers
41 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
27 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 ...
-3
votes
1answer
45 views

code coverage for this class in test class is 67%..need more .Please Help..Beginner in Coding [duplicate]

Class public with sharing class MobileForms2 { public list<SelectWrapper> AccountList {get;set;} public string SelectedAccountId {get;set;} public list<FormWC> FormList {get;set;} ...
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 ...
-2
votes
0answers
11 views

How to i get coverage for this methods [duplicate]

Could you help me on getting test method coverage: public static String insertarLog(String strInterfaz, String strSolicitud) { Logs_Interfaces__c objLog = new Logs_Interfaces__c(); objLog....
-1
votes
2answers
51 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
40 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
57 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
16 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
20 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
20 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
14 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
31 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
62 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
31 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
41 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
53 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
32 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
34 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
23 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
59 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
40 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
36 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
31 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&...
0
votes
0answers
17 views

Trigger.newMap and Trigger.oldMap not able to pass the correct values in the test Class! [duplicate]

I have a scenario to cover in the Test Class Whenever Case is assign to queue from User : particular field must get blank: public static void wmgRemoveOldGroupQueue(Map<Id,Case> newMap, Map&...
-2
votes
1answer
21 views

Error: No more than one executeBatch can be called from within a test method [duplicate]

Test Class: @isTest private class UsersFreeze_batch_Test{ static final String COMP = 'HID Global'; static final list<Countries__c> COUNTRIES = new list<Countries__c>([...
0
votes
0answers
32 views

How to validate Old and New Values of ContactHistory in Test Class

I have an apex class which looks for the old and new values of contacthistory. I am writing a test class for this, but could not write data to Oldvalue and Newvalue. I also tried updating the field ...
0
votes
0answers
14 views

Test Class Failing for a Batch Apex Class [duplicate]

I have created a test class which tests the code for a batch apex class but the code coverage is only 62%. I'm really stuck and don't know how to get over it. I'm new to salesforce and any help would ...
0
votes
0answers
15 views

Test Class Code coverage Improvement

My test class @testSetup static void createTestRecords() { User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ]; System.runAs( thisUser) { //creating User ...
0
votes
1answer
30 views

REST Endpoint Returns NULL in Test Class

I have a RestResource mapped to /Demo/ that I place on a Salesforce Site. The rest resource works great, including the parameters. However, in my test class I cannot get it to return anything to ...
-3
votes
1answer
71 views

Not able to get the expected Assert statement in my test Class

My Assert Statement is failing in the below logic and i am not able to get the proper expected value , Please find the Codes in the Screenshots. Logic: public static void wmgRemoveOldGroupQueue(...