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
0answers
22 views

MIXED_DML_OPERATION Error in Test Case with S2XUserMap

Before starting, I know about DML operations and the order they should be performed in for test cases. Please do not comment on that. These test cases succeed and have been succeeding in partial and ...
0
votes
1answer
38 views

Update own User in apex class [closed]

how may I update own user profile? I have below code I need update user field of runAs user @isTest static void xyzMethod() { Boolean errofFlag= true; User userXYZ= createUserWithProfile('...
4
votes
2answers
231 views

'Guest users cannot be record owners' error during deployment of test class to production

I have increased test coverage of a class in QA Sandbox and I am trying to deploy that test class to production. When I run the test class in QA Sandbox, there is no error. But when I am deploying it ...
0
votes
2answers
34 views

Rest API Test Class Problem

I am having some problem while testing my rest API Class. My main class is as mentioned there @RestResource(urlMapping='/ONB2__Subscription__c/*') global with sharing class SubsRecord { @HttpGet ...
0
votes
0answers
11 views

Test succeeds in packaging org, but fails during packaging

We are trying to avoid using globalDescribe as that can eat a ton of time in larger orgs. So we are trying Type.forName to get SObjectType and their describes without hitting the costly global ...
0
votes
2answers
25 views

Apex Test Class Error on FinancialForce Sales Order Object

I've been trying for a few days to get this to work and but I've run out of ideas. I'm stuck. I can't get this test class to work. I get the following error. Trigger trigger efs_Sales_OrderTrigger on ...
0
votes
1answer
24 views

System.assertequal fails but debug log shows id

I have a test class that keeps failing on the last assert. The debug shows the newly created system record so not sure why it keeps failing. Location_c location = new Location_c( Name = '...
0
votes
1answer
38 views

After Update Test Class Is Not Committing Change

I'm working on a test class for an after update trigger and I am running into an issue where the change that is being done is not being comitted by the DML operation. For example, if I look at the log ...
1
vote
1answer
42 views

SFDX Test Cases Failing only on Package Version Create

EDIT: If you are using a CI flow, ensure that it isn't creating profiles for you when running test cases. That was the main issue for me when using cumulusci. I am trying to deploy a package version ...
14
votes
2answers
652 views

Salesforce 2020 release has blocked all Apex tests that use http mocking

We have 100+ tests failing now that our main testing sandbox has received the 2020 release. We can no longer deploy. We're getting many errors like Unexpected error: You have uncommitted work ...
0
votes
0answers
41 views

Confounded by Test Class Failing in Production but Passing in all Identical Sandboxes

I finally have to ask some other folks about this one. There's a test class from an (awful) unmanaged package in our org, and it has been there for a year and never been a problem, but suddenly it is ...
0
votes
1answer
25 views

Test class for updated field value

I have a class that is scheduled using CRON. I have created a test class and the test for the CRON is tested ok. However, the field update is not being tested and I cannot see why. Coverage is 57% ...
0
votes
1answer
20 views

How to create Case with Person Account in test class

@isTest public class TestDataFactory { public static List<Account> createPersonAccount(Integer numOfAccounts){ Id prsnAccountRecTypeId = Schema.SObjectType.Account....
0
votes
1answer
54 views

Assertion in the Test Class for ApexRest

I have a Apex Class which is exposed as a Rest API, the method is current void like below @RestResource(urlMapping='/SFDataAPI/*') global with sharing class SFDataAPI { @HttpGet global ...
0
votes
1answer
44 views

Date literals returning nothing in Apex Test

I'm doing the following in a test class. First inserting one record and then doing a record count to see that there is still only the one record in the DB. However when the query runs I get 0 records ...
-2
votes
1answer
50 views

Test Class to execute catch blocks [duplicate]

I have a Apex Class like below for handling the exception public class updateCaseRecord { @AuraEnabled public static void updateCheck(String caseId, String Status){ String msg = ...
0
votes
1answer
26 views

Testing chained continuations

Im wondering if anyone has figured out a way to test chained continuations? I followed the documentation for how to essentially make two asynchronous callouts in a synchronous pattern. I can test the ...
1
vote
2answers
24 views

You have uncommitted work pending error

I am getting a "you have uncommitted work pending" error on a test. Normally this is caused by a DML statement before a callout. That shouldn't be the case here. However, the code runs fine and I am ...
1
vote
2answers
106 views

Test Class for the Apex Class with try Catch block fails

I am trying to write a test class for the Apex Class with try - catch block and this is my first time coding test classes. The Apex Class is like below which has trycatch public class ...
-1
votes
1answer
25 views

Test Class for adding error message [duplicate]

@isTest public class ConvertTestClass { public static testMethod void test1() { Lead__c ld = new Lead__c (); ld.First_Name__c = 'Test'; ld.Name ='first'; ld....
0
votes
1answer
23 views

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

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
28 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
37 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
60 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
30 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
24 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
24 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
27 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 ...
5
votes
0answers
62 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
30 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
51 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
86 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
31 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
32 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;...
1
vote
0answers
35 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 ...
6
votes
1answer
137 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
32 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
35 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
74 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
74 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
34 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
50 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
53 views

AuthProvider is visible from Test Method

@isTest public with sharing class AuthProviderCtrlTest { @isTest public static void getAuthProviderTest() { List<AuthProvider> providers = AuthProviderCtrl.getProviders() ...

1
2 3 4 5
8