We’re rewarding the question askers & reputations are being recalculated! Read more.

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
2answers
18 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
50 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
1answer
27 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
27 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
32 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
12 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
24 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
34 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
45 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
34 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
30 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
55 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
45 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
60 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
22 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
42 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
32 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
31 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
27 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
44 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
60 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
63 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
28 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
26 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
vote
2answers
69 views

How can I create 1500 contacts for my units tests without hitting CPU limit?

I am creating a script that gets run every quarter that checks for any paid status in campaignMember objects that has contactId attached, and update the status to unpaid and create a campaignMember ...
0
votes
0answers
72 views

APEX Test Class: Round Robin Lead Distribution Model

The original question can be found here. However, as an overview, the code is responsible for assigning Leads to sales representatives with round-robin distribution based on the Queue that is assigned ...
3
votes
2answers
417 views

Process Builder causing Apex Test class failures - How to handle?

Hoping someone can help with the following issue I am currently experiencing. I have created a new process via the process builder that sets the Contact owner to be the same as the Account Owner on ...
2
votes
2answers
166 views

FIELD_INTEGRITY_EXCEPTION, High Volume Portal Users cannot have a user role - Test class

The user role created below is not 'High volume Portal User' but, still production deployment validation fails with error "FIELD_INTEGRITY_EXCEPTION, High Volume Portal Users cannot have a user role". ...
0
votes
1answer
40 views

Task execution of AfterInsert Error for Task Trigger CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

So I have a trigger and a class that works perfectly when I manually test in sandbox but when I run a test class, I get the below error: 13:50:50:330 EXCEPTION_THROWN [49]|System.DmlException: Insert ...
3
votes
1answer
398 views

sfdx force:apex:test:run all local tests failing

I have a sandbox org (not scratch org). I authenticated it with alias e-devint When run RunLocalTests (hundreds apex test files), it fails quickly with the error below. The error doesn't tell much. ...
0
votes
0answers
222 views

How to create a correct test for knowledge articles?

I'm creating a package with a simple Apex class that retrieves info about knowledge article (Lighting Knowledge). However, I'm having an issue with a test. When installing the package via installation ...
0
votes
0answers
74 views

Unable to write BestCommentId on FeedItem in test class

I am trying to write a test class to test an Apex class that uses FeedItem object. The Apex class checks if the FeedItem record has a BestCommentId and does some actions. A snippet of the test data ...
0
votes
0answers
43 views

System.ListException: List index out of bounds: 0 in test class when we try to query ProcessInstanceWorkitem [duplicate]

I am getting List index out of bounds exception when I try to query ProcessInstanceWorkitem in test class. Below is the code snippet in the main class: ProcessInstanceWorkitem[] piw = [SELECT Id ...
2
votes
2answers
37 views

Apex Test Class Failure: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

I am at a loss for this one and could really use some help on this. I have a vf page and apex extension that is used with a site. Everything works when I test this via the UI but for some reason I am ...
0
votes
1answer
389 views

How to solve this deployment errors (Variable does not exist: isReadOnly)?

Trying to deploy package (big one) to a new org but all the tests failed with very weird errors: 1)line -1, column -1: Dependent class is invalid and needs recompilation: Class ClassName : Variable ...
3
votes
2answers
162 views

How is it possible for @TestSetup to effect test result?

While refactoring a test to make it more consistent with the style of our other tests, a colleague came upon something really weird. The original test created the test account in @TestSetup, like so: ...
8
votes
1answer
131 views

Set.retainAll () on API 45 dies with UnexpectedException

I have a weird issue, can somebody help? On API 45, the following test crashes with FATAL_ERROR System.UnexpectedException: java.lang.String cannot be cast to apex.bytecodeinterpreter....
0
votes
2answers
35 views

TestMethod do not support Web service callouts

I want to invoke a Process from the record base Process using invocable apex which invokes Process by making an HTTP request to the Rest API. But when I try that it's causing many of our existing ...
0
votes
0answers
42 views

Test Classes: MIXED_DML_OPERATION

Via Process Builder, Is there anything I can do in my process that could stop this from occurring? Error Message: System.EmailException: SendEmail failed. First exception on row 0; first error: ...
-1
votes
1answer
42 views

Test CLass code coverage problem

trigger Updaterelatedoppty on Account ( after update,after insert , before insert,before update ) { //before trigger if(Trigger.isbefore ) { for(Account acct :Trigger.new){ ...
0
votes
2answers
259 views

Inner Class Cover in Test Class

Please help me why my code coverage is showing 0% . See my class code and test class code where I have written wrong? Class public class InnerClass { public class Wrap { public string ...
0
votes
2answers
93 views

Test Class - Error - Constructor not defined

Error - Constructor not defined: [PrepareSandboxPostCopy_Batch].() Test Class @isTest private class SandboxPostRefreshTestCase { static Testmethod void testSandboxPostCopyScript() { ...
1
vote
2answers
47 views

Insertion Failed

I was writing the test class and found the below error and i am unable to figure it out .. System.DmlException: Insert failed. First exception on row 0 with id a0D1h0000003rUREAY; first error: ...
0
votes
1answer
42 views

Malformed JSON: Expected '[': wrong test, callout or mock?

I have System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set and I don't know how to fix it. Callout: public class Callout { public List<Tool__c> toolsList; public ...
1
vote
1answer
565 views

Test Class for Trigger before insert before update

I am very new to APEX and I have written the following trigger that updates the due date on a case based upon an SLA value stored in another object once the user fills a value in a lookup field ...
-1
votes
1answer
49 views

Test Class failing due to Mixed DML Operation Error on User

Error :- System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (...
0
votes
1answer
29 views

How to fix wrong test controller's filter by status?

public void byStatus(){ //Temporary multipicklist, because my main picklist isn't multiselected: String temporary = jobAdvertisement.Temporary__c; List<String> temporaryList = new ...
1
vote
1answer
140 views

Apex tests cannot be enqueued during a test ERROR

Below is the excpetion, System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Apex tests cannot be enqueued during a test. It happens ...