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 ...
0
votes
1answer
20 views
Cover Helper Class
I have a class that I wrote that maps dates to specific fields on a custom object and that is it. How would you test this if there are no dml statements? How would you assert that a value is correct? ...
0
votes
1answer
36 views
Apex Test Method Passed But No Code Coverage
Sample1__c (Id,Name,chkbox__c,Sum__c)
Sample2__c (Id,Name,Sample1__c,Num1__c)
Sample3__c (Id,Name,Sample1__c,Sample2__c,chkbox__c,Num1__c,Sum__c,Other_Field__c)
Sample1__c is the master of both ...
-1
votes
0answers
22 views
Test code for the below apex code [closed]
public void submissionFromFPVVSharepoint(String conId, String conAmendId, String billingAcountBuagNo,string sapInteractionNum,Map <String,String> SiteIDWithDate)
currently mentioned as :
mvc....
1
vote
1answer
40 views
Test class failure on Case Object
I'm blocked in creating a Record for PartnerNetworkConnection.I'm getting an error like
QueryException: List has no rows for assignment to SObject.
Stack Trace: Class.caseForward.forward: line ...
-3
votes
4answers
69 views
Test Class for Trigger is not providing coverage
I have created a trigger that makes a field a value based on certain criteria. I have the trigger written and I have the test class, however for some reason I only get 29% code coverage when run the ...
-4
votes
1answer
49 views
how to write test class for the below code, i didn't understand the code can anyone help me out for this [closed]
global with sharing class approvalRequests{
public ProcessInstanceWorkitem piw{get;set;}
public List<plantype__c> plantype_Temp = new List<plantype__c>();
public class pwiWrap{...
0
votes
2answers
45 views
How to write a Test class for after Delete Event
Can anyone help me to write a Test class for below Trigger
trigger DeleteCRonContactDeletion on Contact (after delete) {
set<Id> contactIds = new Set<Id>();
for(Contact objCon:...
2
votes
1answer
186 views
How to test a class that contains no methods
I have a class that only contains one map.
public with sharing class testController {
public Map<String, User[]> mapName {get {.....return value;} set;}
}
I am unable to instantiate the ...
0
votes
0answers
27 views
Why code coverage of inbuilt classes in salesforce is not 100% and can we make it 100%
I just realized that some built-in apex classes have less than 100% code coverage.
eg.
The ForgotPasswordController class has 88% code coverage(8/9 lines covered)
The MyProfilePageController ...
1
vote
1answer
25 views
Duplicate error test class
I can't test some rows in my code with duplicates, I try to make duplicate error in different ways but nothing helps. Could you assist?
Apex Class:
public class AccountExtensionController {
public ...
-3
votes
0answers
29 views
Why i get “List index out of bounds: 0” error when i try to deploy to production? [duplicate]
The test class is working fine in my sandbox environment, but for some reason when in my production environment it fails and gives me the following message:
System.ListException: List index out of ...
0
votes
3answers
47 views
apex test class fails to get rows, why is that?
i wrote a test class that is working fine in my sandbox enviroment, but for some reason on production it fails nad gives me the message:
"System.QueryException: List has no rows for assignment to ...
0
votes
2answers
33 views
Is there any way to get list of all apex classes along with code coverages?
I wan to check code coverage for individual Apex class after I ran all test classes.
Is there way way where I can fire SOQL query get the list of All apex
class along with individual code ...
3
votes
1answer
60 views
Unable To Cover StandardSetController.getSelected Loop
I cant seem to figure out why the creation of this custom object is not getting hit by my test class. Any help would be greatly appreciated.
Here is the test class:
@isTest
public class ...
7
votes
2answers
344 views
Code Coverage Calculation - Seems to be including code in test methods
According to the documentation:
Test classes (classes that are annotated with @isTest) are excluded
from the code coverage calculation. This exclusion applies to all test
classes regardless of ...
1
vote
2answers
65 views
I need help bulkifying this code… I keep getting either DML error count or SOQL error count
I'm writing my first APEX trigger and test class, However I'm:
1 this code does EXACTLY as I want it to do when an individual changes "Account Status"... but I know it won't work for mass uploads
...
0
votes
1answer
39 views
Can't seem to get this trigger 100% coverage. Any Ideas?
Can't seem to get above 65% test coverage, I have marked where I am lacked coverage as far as I can tell it should cover this area but I am clearly missing something, any ideas?
RelatedContactClass
...
4
votes
2answers
61 views
How to test Javascript is equal to Apex as possible
How do you manage to test your Javascript code with the same high standards as your Apex code?
Which frameworks worked best for you?
Is there a way to run JS tests from Apex Test so that they run ...
0
votes
1answer
18 views
How to cover code related to Custom Metadata logic?
I have a custom metadata called Custom_Metadata__mdt.
I have one custom boolean field in that custom metadata called Custom_Boolean_Field__c.
I need to execute some logic only if value of ...
0
votes
1answer
25 views
Please help me writing the test Class for Aggregate function and Charts
Using below code im generating the Chart on VF page, I'm unable to write test Class for the below code Please help me solving this.
public List<PieWedgeData> getPieData() {
List<...
0
votes
1answer
22 views
Catch block coverage with no dml/query in try block
Is there a way to cover the following catch block without of course doing test.isRunning.
Try{
Id bId = Func1();
Schema.DescribeSObjectResult result = Obj1.SObjectType.getDescribe();
...
0
votes
1answer
15 views
Apex Test Method for After Delete Not Covered in Apex Trigger
I have an apex class that updates a field. This class is called by two apex triggers from two different custom objects that fire after insert, update, and delete. But after I ran the test class, only ...
0
votes
0answers
25 views
DeepClone not Covered in Test Class
I have the following code to clone a lead upon specific criteria (code works, test class works, not proper coverage on trigger though):
private void leadDupConvert()
{
List<Lead> ...
0
votes
1answer
34 views
Testing Method stuck at 25%
Here is the controller
public with sharing class QuoteClone {
public Opportunity opp { get; set; }
public QuoteClone() {
opp = new Opportunity();
}
public pagereference ...
0
votes
1answer
25 views
Help with test coverage for implementation of QuickAction.QuickActionDefaultsHandler
I have an Apex Class 'EmailPublisherLoader', which implements QuickAction.QuickActionDefaultsHandler, to set dynamic Email Templates, Recipients and From address in the Case Feed Email Publisher.
I ...
1
vote
0answers
16 views
Enforce DML statement to be failed within a batch
I am trying to make a DML statement in a batch to be failed.
The reason for this is that I have logic executed in my batch in case the DML failed for some records. I would like to test it and get the ...
0
votes
2answers
53 views
How can I successfully cover these lines in my Apex class?
My test:
@isTest
private class CampaignRelatedListExtensionTest{
static testMethod void validateCampaignRelatedListExtension()
Account acc = new Account(Name = 'Test Account', ...
0
votes
1answer
24 views
Site.getName() is null for test class
I am trying to code a test case for my Apex Class that is used on a Visualforce page.
The problem that I am having is this block of code:
String siteName = Site.getName();
if (siteName == '...
0
votes
0answers
27 views
Test class for webservice method
public static String[] sendPartnerAPIRequest(ControllerClass parentController) {
String jsonBody = getPartnerAPIRequestPayload(parentController);
String endPointURL = System.Label....
0
votes
1answer
74 views
milestone completion test class not getting 100% code coverage
I have created the milestone completion trigger based on Salesforce's documentation (https://dreamevent.secure.force.com/articleView?id=entitlements_milestones_trigger.htm&language=en_US&type=...
0
votes
2answers
34 views
Exception testing in Test Method
My actual method is something like :
public static string Method(String input ) {
String Output;
try {
Output = StringFunction(Input);
} catch(Exception e) {}
return output;
}
...
0
votes
0answers
51 views
Cannot Produce Code Coverage, what am I doing wrong here?
Apex Developers,
I cannot seem to produce any code coverage for the below. I've gone through the basic troubleshooting steps (Clear Test Data, Rerun all Tests, etc).
public class ...
1
vote
1answer
35 views
How to write test class for chained enqueued jobs?
I have an Queueable class which enqueues second job and now i want to write test class for the Queueable class. How should I cover my code in the second enqueued class of my test class?
As specified ...
1
vote
1answer
15 views
Test Class Input
I have a Batch class:
global class updateCusotmerMasterData implements Database.Batchable<sObject>, Database.Stateful,Database.AllowsCallouts
{
public updateCusotmerMasterData(){}
...
0
votes
1answer
18 views
Test Class Error in salesforce
I have a Batch class:
global class updateCusotmerMasterData implements Database.Batchable<sObject>, Database.Stateful,Database.AllowsCallouts
{
public updateCusotmerMasterData(){}
...
1
vote
1answer
27 views
Test Class Showing Error
Batch class code:
global class updateCusotmerMasterData implements Database.Batchable<sObject>, Database.Stateful,Database.AllowsCallouts
{
global Database.QueryLocator start(Database....
0
votes
0answers
18 views
How to wirte a test class [duplicate]
Batch class code:
global class updateCusotmerMasterData implements Database.Batchable<sObject>, Database.Stateful,Database.AllowsCallouts
{
global Database.QueryLocator start(Database....
0
votes
2answers
44 views
Unable to Cover 100% test class due to return null
below is my code
Public Class Testmanage{
public Testmanage(ApexPages.StandardController controller) {
}
public pageReference load()
{
if(ApexPages.currentPage().getParameters(...
1
vote
2answers
43 views
Test Class - Unable to select a picklist value from field having reference to Global Picklist
I am trying to create an object's instance in a test class. While assigning some value to a picklist field which gets its value from a global picklist, I get this error:
bad value for restricted ...
0
votes
1answer
32 views
Skip some classes while running the test coverage
Is there any way to skip some classes while running the test classes. We are evaluating the test code coverage and we have some classes which are not completed yet so we want to skip these uncompleted ...
0
votes
2answers
67 views
Deploy: Failed Code Coverage Error When Deploying Apex Trigger [closed]
When I run a test in developer I get 77% apparently. This is the entire apex trigger and the only thing that is being attempted to be deployed in the org:
trigger Requestor on Case (before insert) {
...
0
votes
1answer
18 views
Help required to get full code covered in test class
I am having the trigger and handler class in the quote Line Item object it's work like, the I am having two same named custom field in the OpportunityLineItem and Quote Line item respectively.so that ...
2
votes
1answer
19 views
Help with Tests for Apex Class for User Profile Picture
I came up with an Apex Class to extract the User Profile Picture, to be used in a VisualForce Email Template :
public class UserProfilePicture {
public String profileImageUrl { get; set; }
...
1
vote
2answers
85 views
How to write a test class for following trigger in effectively?
I have done following function to the help of apex class and trigger. the concept is like the sync mode in the quote to that related opportunity if we created any product in the quote line item that ...
0
votes
1answer
24 views
Test class code coverage - Syncing custom fields between quotes and opportunities (Custom Quote Sync)
I have copied the code from the blog amitsalesforce for syncing custom fields from Opportunity Line Item to Quote Line Item on creation of Quote.
Made small changes in that code and that works fine ...
0
votes
0answers
21 views
overall coverage of test class
Is there any possiblity to check overall coverage of my team test class coverage percentage. there is two team one is mine and in that there are 45 classes and overall 93 classes and i want to check ...
1
vote
1answer
24 views
Code coverage issue for apex code with countless run options [closed]
We have a custom-developed price calculator which covers so many possible run options that make it hardly impossible to include all possible calculation options in a test class, hence minimal code ...
-4
votes
2answers
28 views
test class is not working [closed]
I worte the below helper class and it is working perfectly, but I have an issue with the deployment because of the test class
public class CESExtension {
public CES__c CES;
public opportunity ...
0
votes
1answer
16 views
How to cover undelete method in test class for trigger
How do I cover the after undelete process in test class for the trigger. The lines which are not covering is below,
public void executeOnUnDeleteAccount(list<Account> accountNewList) {
set&...
1
vote
1answer
35 views
Code Coverage Report Scheduler
I created a scheduled job to run all tests in org at 5:30 AM,
and another one at 6:00 AM(to ensure that all test jobs done) to send the code coverage percentage and top 10 uncovered classes in org,...