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
3 votes
0 answers
65 views

Apex tests fail in Dev Console Test Suite but pass when run individually

Background There is a test utility class Class is marked as @isTest There are 5 methods Methods are not marked as @isTest because they have parameters All methods are static All methods call ...
user avatar
  • 2,119
0 votes
0 answers
29 views

Getting full coverage for test class for boolean value? [duplicate]

This UserMigrationRoute class is migrating Community profile users to Partner profile and saving their username Password in userMigration object. I have really hard time writing test classes. I have ...
user avatar
0 votes
0 answers
14 views

Test class for files upload method using contentDocumentlink for Guest user [duplicate]

I was trying to write a test which will take input as a file upload field and store file onto a dummy record then attaching it to the Lead record and removing those dummy record data after attaching, ...
user avatar
1 vote
1 answer
22 views

Test Method Issue for removing duplicates from List

I have a requirement to remove the duplicate objects from a list at several places in my integration code and I have developed a method in the Util class to remove the duplicate objects from the list. ...
user avatar
0 votes
0 answers
30 views

How to Find Debug Logs in Apex Test Class

Hey there this is my first Apex code and I'm having trouble finding my debug logs. Heres my Trigger and Test Class First, then below I'll try and explain all that I've tried so far. trigger ...
user avatar
0 votes
1 answer
25 views

Test Class Error for Apex Class meant to filter Quote Lines on a VF Email Template

I'm just starting out with Apex, really any SF development. I've been lucky enough to be able to learn and practice what I've been learning in real-life scenarios, but I've depleted my googling skills ...
user avatar
  • 5
-1 votes
1 answer
24 views

Getting Too many Email Invocations: 11 for the test class

Getting Too many Email Invocations: 11 error.. have no idea to resolve that error Any help is much appreciated. This class is used to send email notification to groups when a case created/updated apex ...
user avatar
  • 3
0 votes
0 answers
45 views

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, role type must match user type: []

I Am getting this error System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, role type must match user type: [] Stack Trace: Class.TestDataFactory....
user avatar
  • 1
0 votes
1 answer
26 views

Do triggers in salesforce have test class created by salesforce not by the developer?

I am using Ant Migration tool to deploy or retrieve my metadata in salesforce. I have a LeadTrigger that I fetch but when I was running the test before I deploy, I got the error that I didn't reach ...
user avatar
0 votes
0 answers
19 views

Why would deploying an Experience Bundle affect DateTime values in unrelated unit tests?

We have quite a few unit tests failing that do time conversions between time zones, but only when we try to deploy one specific experienceBundle through sfdx. We can remove that experience bundle and ...
user avatar
  • 41
0 votes
0 answers
13 views

Owner.Name is showing Null For Lead Record in Test Class [duplicate]

There are two test methods. First method insert the account and then queried the Correct Owner.name. And Second Method insert the Lead and then queried the null Owner.Name. Please let me know, how ...
user avatar
-1 votes
1 answer
26 views

Trigger getting Coverage on Insert but not Update

Why This Question is Necessary: It is clear that this question get's asked quite a bit on here, but the examples in other questions are oversimplified (for example the post had a "redundancy"...
user avatar
  • 1,268
1 vote
1 answer
32 views

Lead conversion in test class error - Invalid Converted Status

I have a test class that's doing a Lead conversion that's resulting in an "Invalid Converted Status" error. This is the part of the test class that's converting the lead: Test.startTest(); ...
user avatar
1 vote
0 answers
30 views

2gp tests are failing with 'No such column' when trying to access current package field dynamically from base package test code

We have our 2gp package B which depends from package A. We've also added new custom field into package B but for custom object from package A, like extending base package object with our own ...
user avatar
  • 2,734
1 vote
0 answers
163 views

test class OrderSummary

Hi I am creating a test in which I have to insert an OrderSummary, I have tried many ways but I can't find a solution. In this post the same thing has happened but there is no solution posted. Code ...
user avatar
0 votes
0 answers
51 views

Test Method is success in one org and failing in another org

I am running my test method in dev org which is successful but when I am running the same method in another org, I am getting error : System.DmlException: Update failed. First exception on row 0 with ...
user avatar
0 votes
0 answers
45 views

Salesforce Apex class update the region field in contact record

I am trying to update region field based on country of residence and nationality, for example if nationality is UK, and country to resident is UK then country of region should be UK as well but it is ...
user avatar
2 votes
1 answer
43 views

Test fails in production with "Methods defined as TestMethod do not support Web service callouts" but passes in brand new sandbox

On a test class for a class that handles lead conversion via apex, 6 out of 7 methods (the ones that convert the lead) are failing in production. However, I can run the test in a fresh sandbox and it ...
user avatar
  • 4,215
9 votes
1 answer
279 views

Spring 22 testmethod GACK when assigning a PermissionSet to a newly-created user

If you have this testmethod: @IsTest private class NewSysadTest { @IsTest static void testSuccess() { User testUser = new User( username=UserInfo.getUserId()+'.'+ (DateTime.now()+':'+...
user avatar
  • 62.3k
0 votes
1 answer
185 views

Test class for Transaction Finalizer is not working

I am stuck in the test class for the Transaction Finalizer class. Every time when we create an exception for Queueable class then Finalizer class executing and then the test class throws the error on ...
user avatar
0 votes
1 answer
27 views

Contact and Account Errors With Testing Apex Trigger

I am trying to use Apex to extract Contact information and create the json to send to our server for updates. This has worked until I added a bit to include a field from the Account object - which ...
user avatar
3 votes
1 answer
77 views

Flaky apex tests fail unreproducible with UNABLE_TO_LOCK_ROW when inserting Product2

Recently, our tests started to fail randomly with the dreaded UNABLE_TO_LOCK_ROW. The only fix seems to "Restart on Failed" the pipeline until it succeeds. This is the fixture code in ...
user avatar
  • 1,330
0 votes
1 answer
306 views

CaseMilestone on Apex test class

I have been trying to test a business process that uses Case/Entitlements/EntitleMent Processes/ and CaseMilestones. All these components are working just fine and there are not issues whatsoever in ...
user avatar
0 votes
1 answer
376 views

Error: Opportunity must have a primary quote in order to create an order.: [] - SBQQ CPQ Test class

I am very new to CPQ, and I am given a test class to write directly. When I try creating order in my test class, I am getting this error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Opportunity must have a ...
user avatar
0 votes
0 answers
51 views

Help With Understanding Error System.QueryException: List has no rows for assignment to SObject

I am new to apex and im trying to do my first deployment of a visual force page. Im trying to deploy my apex classes and their tests but i'm getting this error below. I have tried changing the ...
user avatar
0 votes
0 answers
23 views

Permission Sets giving issues in Apex Test Code

I am getting this error from the Developer Console: System.QueryException: List has no rows for assignment to SObject For this specific line in my test: PermissionSet ps = [SELECT Id FROM ...
user avatar
  • 1
0 votes
1 answer
47 views

Test Class for Scheduled Batch Class - Error

I have a scheduled batch class that will eventually run on the 1st of every month. It's designed to find records from an Asset that are linked to Accounts, aggregate the counts of these records into 3 ...
user avatar
  • 1,183
2 votes
1 answer
112 views

IntellJ : Test being ignored cause it does exists in server

The issue is related to The intellj plugin : Illuminated Cloud (for SFA), the issue is when i make some local changes and want to run some test i keep getting Test method mehod_name was never reported ...
user avatar
0 votes
1 answer
47 views

Why am I getting an Uncommitted Work Pending error when deploying?

I am unable to deploy this code because I am getting an error stating the following when a test class is run on it. This is the error : System.CalloutException: You have uncommitted work pending. ...
user avatar
  • 3,730
0 votes
0 answers
43 views

Test class for Messaging.SingleEmailMessage [duplicate]

I wrote a batch class that send the records in email notification with schedule The batch works, but I'm still struggling to write a test class that will get a high code coverage (currently I get 63%)....
user avatar
0 votes
0 answers
28 views

Unable to do code coverage, now my code coverage is 33% ,can anyone help for 75% [duplicate]

Extension Controller: public with sharing class CreateQuotePDFController { public list<QuoteLineItem> quoteLineItemsList{get;set;} public Id getid{get;set;} public Double ...
user avatar
0 votes
0 answers
20 views

Test works from Dev Console. Fails in automated nightly run

My query was failing with users with a Locale other than "en_US". So I switched the date format from UTC to GMT and it works well. Unfortunately while my tests work when I run them from Dev ...
user avatar
  • 45
0 votes
2 answers
78 views

fflib Tests fail with required fields on Account

I was looking to find out what approach to take with the fflib libraries and testing. I have added the fflib common and mocks files to my project and org. When I run the tests for the whole project I ...
user avatar
0 votes
1 answer
49 views

Apex Test Class throwing NullPointerException

UPDATE NullPointerException error has been resolved (thanks @Adrian) INVALID_PERSON_ACCOUNT_OPERATION error was resolved by adding a RecTypeId variable Now I am confronted by an insert error: ...
user avatar
  • 15
1 vote
2 answers
318 views

How to use a constant in SOQL in a test class

I have the following test class: @isTest(SeeAllData=false) private with sharing class classNameTest { @isTest static testMethod void methodName(){ // declare a constant ...
user avatar
  • 21
2 votes
2 answers
1k views

Data Loader - Bulk Update Failure

I'm trying to do a bulk update of 141 records on a custom object (A2D) using Data Loader. In this bulk update, I have mapped the id field and about 8 boolean fields. When the update is attempted, I ...
user avatar
0 votes
1 answer
117 views

Testing triggers with future methods

According to my functionality: insert and update calls a trigger that invokes future methods. In my test case, I need to test the update functionality. In order to test the update functionality, I ...
user avatar
0 votes
1 answer
393 views

Cannot insert a quotelineitem in my Test Class

I try to insert a quotelineitem in my test class but it fails with this error ,Please help me to resolve this issue . See below my code used in the test class Quote quote = new Quote(Name = 'devis1' ,...
user avatar
-4 votes
1 answer
121 views

Apex test class not working [closed]

I have written a trigger that automatically assigns the value of the 'Status' field from the EmailMessage object to a custom field called 'Last Email Status' on Case object. Below is my method which ...
user avatar
  • 97
0 votes
1 answer
104 views

How to test addError message?

Is there any way to get the message that is included in the addError method in the trigger in order test its contents in the test class?
user avatar
0 votes
0 answers
33 views

I cant get able to get 100% code coverage

Controller estension Class: BOMPage_Class public class BOMPage_Class { public list<Harness__c> HRlist {get; set;} Public list<Raw_Material__c> RMlist {get; set;} Public ...
user avatar
0 votes
0 answers
154 views

2gp: How to debug/fix tests failing ONLY on package version creation

We are trying to create our first major version of new 2gp package and getting some tests failures as result of 'package version create' command. These failures look sort of weird for us (basically ...
user avatar
  • 2,734
0 votes
1 answer
35 views

Apex Class Test Coverage is failing at a particular line

My Apex class test coverage is just reaching 48% and failing at a particular line, not sure why it is happening as I am providing all the data that is necessary. My test class look like below. @isTest ...
user avatar
0 votes
0 answers
26 views

RE: Process builder condition not satisfying in test class

I have written test class where iam inserting the task records and then task status field is updating. Task taskRec1 = new Task(); taskRec1.AES_CNTR__UCID__c = 'abcd'; taskRec1.ARM_Property__c = ...
user avatar
  • 1
0 votes
1 answer
140 views

How to bypass managed package from Test class

Test Class : Account ac = new Account(); ac.Name = 'Test3'; ac.Type = 'Corporate'; ac.BillingCountry = 'DE'; ac.BillingStreet = 'First line' + '\n' + 'Second Line'; ac....
user avatar
  • 2,264
1 vote
1 answer
24 views

Help with Test Failure

I have a trigger that will update campaign members to responded for specific campaign after a specific lead status gets updated in the lead, and this value is specified in custom settings. My ...
user avatar
0 votes
0 answers
426 views

Document.load() fails: System.XmlException: Failed to parse XML due to: only whitespace content allowed before start tag and not {

I am getting the following error when tying to use the Document.load() method for my xml: System.XmlException: Failed to parse XML due to: only whitespace content allowed before start tag and not { (...
user avatar
  • 305
0 votes
1 answer
259 views

Test Class failing for PendingServiceRouting

Working on a test class for PendingServiceRouting to be used invocable methods for a custom apex class. Although while inserting the PendingServiceRouting I am getting Insert failed. First exception ...
user avatar
  • 13
0 votes
0 answers
175 views

Getting error in test class: INVALID_CROSS_REFERENCE_KEY

I am doing a test class for a trigger. Here is the test code. The error happens in line 13, which is inserted @isTest (SeeAllData=false) public class pullCommentsApprovalOCRTest { @isTest ...
user avatar
  • 23
0 votes
1 answer
55 views

How to cover the below lines in my test class 100% code coverage? [duplicate]

Can someone please help me how can I get the code coverage for below line: Test Class Code static testMethod void OpportunityScheduleHandler() { Date Closedt = Date.valueOf('...
user avatar

1
2 3 4 5
10