Questions tagged [failing-tests]

A unit test is code that is written and executed to test a specific portion/unit of source code. Tests that do not pass are considered failing. Tests that do not generate desired coverage are still considered to pass.

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

How to get rid of this System.ListException: List index out of bounds: 0 error in my test class

I am trying to create a new case with record type to cover the lines in my apex class but throwing the inbound error. please help me to cover the lines This is the full method public void ...
0
votes
0answers
10 views

I need help for Test Apex class [duplicate]

I got 52% with this test code, Please give me some advice to improve the percentage for passing. @isTest global class BLmainMock implements HttpCalloutMock { global HTTPResponse respond(...
0
votes
0answers
15 views

RecordType using Test.loadData in Testclass for account object

I am trying to export data in csv from one sandbox and trying to load the same data into Test class using loadData method. Currently , I am struggling in creating RecordType within Test class For ...
0
votes
0answers
29 views

Mixed DML causing test classes to fail to to Process builder

I have a Test class which was working fine but after a new process builder was created on user object to update a custom field created on user object, it started failing. In my test class code I am ...
0
votes
1answer
20 views

Batch callout error: Call out made it firstbefore DML

I have review similar questions, and all of them mention to do API before any DML similar question 1 and similar question 2 However, I am trying to do the API in the excecute, and I am still getting ...
0
votes
0answers
58 views

I don't know how to get 100% code coverage of this code

This code is used to prevent a case from being closed when it still has open tasks. When the user tries to close a case with an open task an error message pops up. Instead of using a Status from the "...
-1
votes
1answer
20 views

Help on System.ListException: List index out of bounds: 0 Error

I'm trying to write test code for my custom controller and got a new error that I haven't gotten before. My research so far has told me that misallocated and/or coming up NULL. Apex Class: ...
0
votes
1answer
19 views

SOQL injection issue on source scanner report

I am getting SOQL injection vulnerability on source scanner report. Please check one of the issue below. I tried string.escapeSingleQuotes() on query string. It is helping with removing this issue in ...
0
votes
0answers
22 views

Getting INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when mocking an Object using Stub API

I am mocking a routing rule object by using the JSON list below that has an ID of type Routing_Rule__c. The Test is about creating some rules and setting some flags that would cause the lead object to ...
0
votes
1answer
16 views

Workflow Task Error When Trying to Deactivate a User from a SandboxPostCopy Apex Test

I'm trying to deactivate a user in an apex test. But am getting an error that the user (that I just created in the test) in being used by workflow tasks. The class implements SandboxPostCopy and is to ...
0
votes
0answers
18 views

Apex Test Class is Failing - (System.QueryException: List has no rows for assignment to SObject) [duplicate]

I am brand new to coding and this is my first test class. I have spent hours trying to get it to pass. Apex Trigger That I am Testing trigger RenameTransaction on Financial_Transaction__c (before ...
4
votes
0answers
46 views

Test fails with runAs, queueable and callout in specific org

Has anyone got an idea what could cause the following test to fail in one org and pass in another? The error is System.CalloutException: You have uncommitted work pending. Please commit or rollback ...
-2
votes
1answer
27 views

Error while saving a Test class

I have tried to insert session, speaker and session Speaker object in test class and I am getting error as "Unexpected token 'static'", Unexpected token 'testmethod', Variable does not exist: ...
2
votes
0answers
36 views

Apex test class enable product scheduling

Test Class Error: System.DmlException: Upsert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown (scheduling not enabled on product): [...
2
votes
1answer
84 views

id's on list are not pulling into new list

I am running into an issue with my method for test where I insert contact records that are in a list and then try to pull the id's to associate it with a different list. When I do my debug for the ...
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
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;...
0
votes
0answers
26 views

User Creation via Static resource gives error on Profile Id in Sandbox cloned from the other sandbox

I am getting below error when I am trying to run the test class in Sandbox which was clone from one of DEV Sandbox. System.SObjectException: To create or update users for this profile, go to Setup > ...
1
vote
0answers
34 views

'uncommitted work pending' callout exception thrown in *tests only*

I am converting a lead in the Execute method of a batch class, then making 2 callouts with those results in the Finish() method. It works gloriously and throws no errors. However, in the test ...
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 ...
4
votes
1answer
78 views

Unit Testing problem with Product2 records: A Product with this SKU already exists

I'm using the Product object and store the product sku within the StockKeepingUnit field. According to the Winter 18 release notes, this field is considered unique, which is totally fine and expected ...
-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
2answers
33 views

Methods defined as TestMethod do not support Web service callouts on working test class [closed]

I'm experiencing a wierd thing, I'm made a deployment on a refactoring of code on cases this monday (2019.12.02) and my test classes use the Test.setMock method. It worked so I started doing the same ...
-1
votes
1answer
29 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
2answers
25 views

Apex trigger to update “minutes to first response” not passing test

I have written the following Apex trigger: trigger FeedThis on FeedComment(after insert, after update){ List<Case> updates = new List<case>(); List<id> userList = new List&...
0
votes
2answers
60 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
15 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
1answer
34 views

Apex: Use one test class in another test class

I am working on some email automation and I have a separate test class for each language, kind of like this: @isTest public class EnglishEmailTest { @isTest public static void test1() { .....
0
votes
2answers
32 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
1answer
46 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
0answers
24 views

AuthProvider is visible from Test Method

@isTest public with sharing class AuthProviderCtrlTest { @isTest public static void getAuthProviderTest() { List<AuthProvider> providers = AuthProviderCtrl.getProviders() ...
0
votes
1answer
55 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 ...
0
votes
2answers
119 views

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

Below error I got while running test class.My test class results fail.Anyone have some idea please share with me. Error Details : System.DmlException: Insert failed. First exception on row 0; ...
1
vote
0answers
51 views

Test Class failing with Too many SOQL queries: 101

My test class is public static testMethod void loanSetDelegatedApprovers() { list<User> userList = new list<User>(); list<Approval_Delegate__c> adList = new list<...
0
votes
0answers
53 views

Deployment of apex code to production

I am trying to get rid of some old apex code in a Salesforce org. There are few test classes on production org which are broken because 1) they were written a few years back with old API version or 2) ...
0
votes
0answers
19 views

How to write test class for the below class. I tried alot but it not covering [duplicate]

public class LeadAssignment { public Set<String> nullParamsSet; public LeadAssignment(){ nullParamsSet = new Set<String>(); for (NullParameters__c np : ...
0
votes
1answer
31 views

Ending position out of bounds: 15 in apex Test class

I'm new to apex and stuck with below test class issue. Below is my apex method VF code that calls method1 through actionFunction and apex:param <apex:actionFunction name="deleteRec" action="{!...
0
votes
1answer
78 views

Too many SOQL queries error encountered when running the class in Sandbox but not in Production

I have experienced a bunch of test classes fail to pass in a Sandbox, but execute fine in Production. Has anyone some good tips on what look out specifically? I think the code itself is not ...
0
votes
1answer
56 views

List must not have two identically equal elements: bulk test

I have after insert Trigger and I'm trying to test it with this logic (for bulk testing). It's a little test from Execute Anonymous Window: List<Lib__c> lb = new List<Lib__c>(); string s =...
-4
votes
2answers
88 views

Filter Id value is not valid for the Object standard controller

Now it works :) Thank you guys! public class VFController { public VFController(ApexPages.StandardSetController setCon){} public ApexPages.StandardSetController setCon { get { ...
1
vote
0answers
23 views

Batch fails to deploy

I have a batch that I uploaded into Production successfully on July 20th and then a change to that batch on July 27th, both with no issues. I needed to make another change to that batch today, so I ...
1
vote
1answer
71 views

Test Class Failing : DML Exception

I'm having trouble getting my test class to pass tests. Getting: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Select from Add ...
2
votes
0answers
51 views

In a test class example of a Post Install script, sending an email and scheduling a class that performs an API callout

Scenario: In my example, as a part of the PostInstall (class implements InstallHandler) script I will be performing two actions; - sending an email to the installing User for the express purpose of ...
0
votes
1answer
32 views

how to make a test so that the lead owner is the same as the contact owner

I'm starting to learn apex and I need to write a test for a simple trigger so I can have 100% code coverage. Here's my trigger: trigger UpdatePropietario on Lead (after update) { Id pId; for(...
0
votes
2answers
99 views

SOSL not returning record in test

I have EditorModalController.searchDoctors that returns a list of contacts. public class EditorModalController { @AuraEnabled public static List<Contact> searchDoctors(String ...
0
votes
1answer
45 views

Why are field updates inside an Apex trigger not showing up in an Apex test?

I have a very strange issue with some Apex tests for a trigger. The tests each check a different type of field update; when one field is changed, the trigger is supposed to change another field. On a ...
-1
votes
1answer
126 views

How to cover the SETENDPOINT kind of lines in test class [duplicate]

**APEX-CLASS** public class TriggerFlodataWorkflowController { public string inputIds{get;set;} public List<String> selectedNames{get;set;} public List<String> selectedIds{get;set;} ...
0
votes
1answer
110 views

Code Coverage 83% in production 75% in sandbox - can't deploy

In production, code coverage is showing 83%. In sandbox, it is showing 75%. I have just 1 apex class and associated test class I am trying to deploy to production, but it fails saying only 30% ...
0
votes
2answers
43 views

How to cater opportunity insertion in my TEST class

I have a method in APEX class that does variety of checks via If else conditions with some SOQL statements. I created test data(Accounts, custom object records) to test the SOQL statements and it ...
0
votes
1answer
27 views

Get test failures dynamically (as it goes) when uploading package, but not all at once in the end of upload process

When we are uploading our huge managed package, it takes up to 3 hours for process to finish and the major part of it are taken by tests execution. The inconvenience here is that tests failures are ...

1
2 3 4 5
8