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

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
20 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 = ...
1
vote
1answer
30 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
13 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 ...
-2
votes
0answers
15 views

How to solve error : Methods defined as TestMethod do not support getContent call [duplicate]

I believe this question has been answered before but all the previous questions has a common problem that they are trying to upload a PDF in a VF page. What I am facing is quite weird. I do not have ...
0
votes
0answers
32 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
97 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
50 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
39 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
48 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
34 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
29 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
31 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
14 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>();...
5
votes
1answer
144 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
43 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
25 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
77 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
36 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
71 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
45 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
44 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
34 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
106 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
173 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
354 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
29 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; ...
0
votes
1answer
93 views

Test for Trigger fails but gives 100% coverage

So I currently just finished writing my test for a trigger that restricts a new or updated contact last name to be "INVALIDNAME". My test keeps failing during the upsert stage and i'm not ...
0
votes
0answers
136 views

Inserting Content Version via Community User in test class Failing

I think this is very straight forward I just can't figure out the issue behind it. Error: : Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You do ...
0
votes
1answer
128 views

Test Class Coverage for Apex Controller [duplicate]

I need help in writing test class for following apex class. Could anyone please suggest how to create test data,test the following method defined in apex class with positive and negative scenarios and ...
1
vote
0answers
58 views

CircleCI, re-run tests that failed in parallel mode during build

note: I'm stuck in an org-centric world, so CircleCI is setup w/my dev sandbox, not scratch orgs. Recently, I set up a CircleCI build to run my sandbox orgs tests w/RunLocalTests on each pull request. ...
2
votes
1answer
86 views

Test Class with HttpMockCallout is throwing error

I am trying todo the Super Badge for the Data Integration Specialist. I wrote the Apexcall that will connect to the external system and send out the opportunity information. When trying to write the ...
1
vote
0answers
60 views

System.SObjectException: Field is not writeable: [duplicate]

We have the following code and Apex Test Class, and for some reason during Apex Test Execution (Developer Console-->Run Test) it is throwing the following error message below. Any ideas why the ...
1
vote
1answer
27 views

how to return the result of a method?

i'm working on a test class and its giving a false positive. i wish to assert the result of the method being tested to see what the failure message is. my test class ends with this Test.startTest(); ...
1
vote
1answer
41 views

sfdx force:apex:test:report is generating false PassRate as 100% though Failures present in the report

I have tried to run the apex tests and generate the test report on source deployed scratchOrg. report is showing Failure's count as 4 and Outcome as 'Failed' too, still shows the PassRate as 100%. ...
0
votes
1answer
83 views

Attempt to de-reference a null Object Email Service Test Class

I'm trying to build a test class for me to move an Email Service class into Prod, but I'm getting this error. Here is part of my code (The important bits) Email Service Class global class ...
0
votes
2answers
98 views

test class error : Method does not exist or incorrect signature

public class MyController { @AuraEnabled public static Account getAccount(String accId){ Account acc = [SELECT Id,Name FROM Account WHERE Id =: accId]; return acc; } } @...
1
vote
1answer
34 views

INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Error When Running Test Class

I've been trying to run my test class via Visual Studio Code, but I get the following error message: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Deployment to org is ...
0
votes
1answer
101 views

Test Class Coverage for Scheduled and Batch Classes

I am attempting to test a scheduled class that calls a batch class to update records. The following test class does not seem to find the Opportunity being created in the test class to pass that list ...
0
votes
0answers
26 views

How can I find out what “uncommitted work” is allegedly pending?

I have two schedulable batch processes, identical in every way except one is for Opportunity and the other is for Appointment__c. In real life, both batch processes work exactly as expected, which is ...
0
votes
1answer
91 views

Error: MIXED_DML_OPERATION Very Confused

I'm very confused about MIXED_DML_OPERATIONerror. Following test case fails in production but passes in uat. @IsTest private class MyControllerTest { private static final String USERNAME ='test@...
-3
votes
1answer
40 views

Test coverage help [duplicate]

One of my customer created below class. I have created a test class to cover but I am unable to cover the code. It seems I have created a correct data but it is not covering .Please anyone help me on ...
0
votes
1answer
36 views

Methods defined as TestMethod do not support Web service callouts error

This is my controller class. public with sharing class RSLeadReportcontroller { public List<RSLeadReport> ConsoleWrapperList{get;set;} public List<RSLeadReport> ...
0
votes
0answers
96 views

When will sending email through Apex automatically cause the test to fail, or when will it pass?

Normally, I expect tests to fail if the org does not allow email deliverability. In my current sandbox, I have several tests that fail because email is not deliverable. I think most of them fail at ...
1
vote
1answer
174 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
39 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
1k 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
65 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
2answers
88 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 ...

1
2 3 4 5
9