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
8
votes
1answer
226 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()+':'+...
0
votes
1answer
51 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 ...
0
votes
1answer
21 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 ...
3
votes
1answer
49 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 ...
0
votes
0answers
35 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 ...
0
votes
1answer
35 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 ...
0
votes
0answers
44 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 ...
0
votes
0answers
17 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 ...
0
votes
1answer
25 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 ...
2
votes
1answer
35 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 ...
0
votes
1answer
42 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. ...
0
votes
0answers
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%)....
0
votes
0answers
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 ...
0
votes
0answers
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 ...
0
votes
2answers
20 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 ...
0
votes
1answer
35 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: ...
1
vote
2answers
122 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 ...
0
votes
2answers
399 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 ...
0
votes
1answer
64 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 ...
0
votes
1answer
159 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' ,...
-4
votes
1answer
56 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 ...
0
votes
1answer
55 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?
0
votes
0answers
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 ...
0
votes
0answers
80 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 ...
0
votes
1answer
24 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 ...
0
votes
0answers
23 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 = ...
0
votes
1answer
54 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....
1
vote
1answer
16 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 ...
0
votes
0answers
169 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 { (...
0
votes
1answer
618 views

FIELD_INTEGRITY_EXCEPTION, Price Book Entry ID: id value of incorrect type: [PricebookEntryId]

Hi all I have a test method which it creates data (makeData) for the following test methods. But I'm getting this message over and over again. System.DmlException: Insert failed. First exception on ...
0
votes
1answer
141 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 ...
0
votes
0answers
53 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 ...
0
votes
1answer
49 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('...
-1
votes
1answer
36 views

Hi, I am stuck there when writing a test class. Please help me rectifying it

The class: And The test Class I have written: @isTest public class AccountAffiliationServiceTest { public static void DataSetup(){ Test.startTest(); Account acc = new ...
0
votes
1answer
93 views

invalid type error calling method from test class

Trying to call a Class method from a test class: Class UtilHelper global class FeeWrapper { global List<Project__c> transToUpdate; } public static FeeWrapper PassingRentFee(...
0
votes
1answer
32 views

System.QueryException: List has no rows for assignment to SObject (in SOQL)

Trying to run a test class: @isTest public class UserRootTest { @isTest static void testRegNow (){ Id guID = [SELECT GuestUserId FROM Site WHERE UrlPathPrefix = 'Tesla' LIMIT 1]....
0
votes
0answers
21 views

Methods defined as TestMethod do not support getContent call in test class [duplicate]

public static workOrderRecordFormApex SAPgetPicklistValues(string recordTypeId, string objectName,string fieldApiName){ Map<String, String> piclistValues=new Map<String, String>();...
6
votes
1answer
290 views

Queueable apex runs in System admin mode even after written in System.runAs mode

Queueable class from Test context runs in test runner mode and not in System.runAs user. This is strange behaviour. Here is the snippet. Any idea? User internalUser = // Created Internal User with ...
0
votes
0answers
110 views

What are possible side effects of "Compile all classes" in production? [duplicate]

When I validate a change set with RunLocalTests in production (as well as using the CLI with that flag for CI/CD and packaging integration) there was a class that was erroring out as a dependency. I'...
0
votes
1answer
56 views

Test with QuoteLineItem insert fails in some sandboxes but not all with REQUIRED_FIELD_MISSING UnitPrice error

I have a test class with setup method which creates an account, opportunity, quote. Then the test method retrieves the quote and sets up a QuoteLineItem . The insert of this QuoteLineItem fails with a ...
0
votes
1answer
115 views

The ApexClass name was not found in the workspace VSCode

Today I started to work on apex test class file after retrieve the source from the Sandbox I realized that the name of file is wrong I deleted the file test and the -meta.xml but when I retrieve again ...
0
votes
1answer
105 views

Can managed packages have hidden validation rules? Keep getting Field Custom Validation Error

I am trying to fix some test coverage. I have about a dozen fails across this org and every test fails for the same reason. The error is: FIELD_CUSTOM_VALIDATION_EXCEPTION, &lt;span style=&...
0
votes
0answers
267 views

unable to obtain exclusive access to this record or 1 records: 07H7Y000000Cc1RUAS - when running tests

I'm getting a peculiar error, something I haven't seen before, when I run test classes. All the failing tests were passing successfully earlier (a week ago). System.DmlException: Insert failed. First ...
0
votes
1answer
54 views

Test class is not covering response

Trigger trigger UpdateRecordEventTrigger on dicecloud__UpdateRecord__e (after insert) { String recordId; List documentIdList = New List(); for(UpdateRecord__e thisUpdateRecord : Trigger.New){ ...
0
votes
0answers
72 views

Does this unit test is correct? Shouldn't it throw an exception?

For a method: @AuraEnabled public static String login(String username, String password, String startUrl) { try{ ApexPages.PageReference lgn = Site.login(username, password, startUrl); ...
-1
votes
1answer
49 views

Why can't I get code coverage for my trigger, even though I wrote a complete unit test? [duplicate]

I need help to create a test class for my trigger below: trigger UpdateLeadLastMQLDate on Event (before update) { Map<Id, Lead> leads = new Map<Id, Lead>(); for(Event record: ...
0
votes
1answer
343 views

0% coverage error on running specified tests while validating/deploying any change set in Production

I am getting 0% code coverage error while trying to validate changesets in production using run specified tests. I tried 3 unrelated deployments and all of them gave the same error. The changesets are ...
1
vote
1answer
274 views

test.starttest() and test.stoptest() not working

Please let me know how to resolve the below issue.I am new to salesforce,its still giving me an error Too many DML statements: 151.Using Test.starttest() and test.stoptest() is not working. Test Class:...
3
votes
3answers
512 views

How to mock System.isFuture()?

I am writing some tests and I have encounter a problem. In my main app I have the following logic: public static void main() { if (System.isFuture()) { System.debug('Is future'); // ...
0
votes
1answer
52 views

Getting Error In Validation : Field Integrity

My test class works fine in sandbox. But When I'm validating this in production getting error mentioned below: OpportunityLineItem opli2 = new OpportunityLineItem(); opli2.UnitPrice = 57; ...

1
2 3 4 5
10