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
5
votes
2answers
450 views

Why is my After Delete Trigger test class failing?

I have a trigger set up on the Account object for After Delete. We have an Affiliates table that has a lookup field to Account. If an Account is merged, I don't want to delete an Affiliate. It will ...
5
votes
1answer
349 views

Is it normal to tests not be able to create queues because there's one with the same name on the organization?

If I have, for example, in production a MyQueue queue, with the same DeveloperName, and I'm trying to run a test class to deploy a change set, which contains a test that inserts a MyQueue queue as ...
0
votes
0answers
144 views

Force calculation of Cross Object formula to be used in test class

The basic gist of my issue is that I have a batch apex class that uses cross object formulas in some IF statements (Something like Contact.Account.FirstName). The problem is that when I create the ...
6
votes
0answers
147 views

Why inserting a user object and making callout in a test throws CalloutException in Production?

I stumbled upon strange behavior when executing tests on deployment to production organization. In the test, I first insert a User object, some other objects and then as the last one, a CampaignMember ...
2
votes
1answer
38 views

Custom Object Relationship query behaves differently in Test from Execute Anonymous

Background I have a custom object Contact_Coverage__c. I have a custom field Contact_Coverage__c added to the Activity standard object, with the child relationship name Activities__r. In general, I ...
0
votes
1answer
40 views

I cannot delete a contact due to “System.NullPointerException: Attempt to de-reference a null object”

I have this trigger: trigger deleteContactReceiver on Contact (before delete) { List<Contact> con=Trigger.new; GDPRContact.deleteContactURN(con); } Invokes: public static void ...
2
votes
2answers
664 views

Sudden MIXED_DML_OPERATION errors without code changes

So I have 3 orgs that are basically all on the same codebase. On the production org (the one that gets changed the least) some of the tests are suddenly failing - all with the same error message: ...
1
vote
0answers
209 views

Apex test classes fail on HTTPResponse

I have some test classes that run decently until they hit something like HTTResponse res = h.send(req); Where I then get 'System.UnexpectedException: Script-thrown exception'. I make a few ...
0
votes
2answers
321 views

Test class error on validation : A flow trigger failed to execute the flow with version ID

I am getting an error when trying to do a validation on a changeset on production. The error that I receive is as below. System.DmlException: Insert failed. First exception on row 0; first error: ...
0
votes
1answer
38 views

production is generating more records in test class, causing failed validation

I created a Lightning Component Controller. It's suppose to clone our custom object pba__Offer__c. In our staging environment, I've managed to get 97% code coverage, and all my asserts pass. Class ...
0
votes
1answer
486 views

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION

I wrote the validation rule to restrict the custom field picklist value it many test classes is getting failed because of that where and what line i can add into picklist value to cover the test ...
1
vote
0answers
336 views

How can I view my test classes debug logs of an ant deploy

I have about 20 classes that I deploy to production via ant. Some of my test classes fail. I want to view the debug logs but I cannot find the way to look at the logs of my ant deployment. Any help ...
-1
votes
2answers
757 views

Deployment failing validation only when two test classes are run

I am trying to deploy a change set which includes to classes and a test class. For validation I am only running two test classes, one which is included in the set and one which is already in ...
3
votes
1answer
2k views

Test.setMock not working in Apex test

I am trying to test the server side Controller in Apex test. The controller makes a call out to get account information and returns the response in an Object format to lightning component. The ...
0
votes
0answers
23 views

Can not reproduce behavior within testcase: Duplicate accounts after merge

I'm sorry for the vague description in the header. So here's my problem in detail: I have an automation, that essentially checks a "potential" child record (not master-detail, just lookup) of accounts,...
0
votes
1answer
112 views

Need to have a workaround for calling a visualforce page whose controller calls a WebService Callout

I am having a custom button on my custom object, which calls a visualforce page by passing the record Id from which it was called. The controller for this Visualforce page is making a WebService ...
0
votes
1answer
88 views

Facing Attempt to de reference null object in test class code coverage

Hi We have a apex class and trying to write Apex class for the code coverage. For some reason the Test class wont pass. Please advise on this Iam getting Attempt to de reference error. Please find ...
0
votes
0answers
93 views

Method being called inside a test method returning null reference

I am calling a method to validate passwords in an apex controller which is working by returning either true, false, or null @TestVisible static Boolean validatePassword(){ if (string.valueof(...
0
votes
2answers
212 views

Test Error & Trigger Null Pointer Exception

I'm attempting to build a trigger that pulls the FullPhotoUrl from the User profile and set a field (FullPhotoUrl__c) on the SFDC_Employee__c object to the url. Here's the error I'm getting I'll paste ...
-1
votes
1answer
407 views

test method fails for execute function in scheduler batch class

I have the following Execute method and want to test it.The test method throws the exception of invalid email, not understanding how can I do it. Also, how can I test the opportunity Code? //Batch ...
2
votes
0answers
477 views

How to Avoid exceeding CPU Time Limit in Test Classes?

I am currently updating test classes in our org and it seems that most of them are exceeding the CPU Time Limit. They are using the @testSetup to create a lot of test data and it seems that these DML ...
0
votes
1answer
475 views

how to call the constructor of the apex controller in the test class

Below is my controller class. Public class VMSalesOrderUserEditpage{ public list<VM_Sales_Order__c> vmList{get;set;} public VM_Sales_Order__c VMSOrd {get;set;} public string vmId {get;set;} ...
-2
votes
1answer
708 views

System.QueryException: List has no rows for assignment to SObject on Trigger

I'm receiving an error message System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FeedItem: execution of AfterInsert caused by: System....
0
votes
1answer
168 views

Need a Help to Cover Scheduler Test Class

Apex Class: global with sharing class SchedularForBatchApex implements Schedulable { global void execute(SchedulableContext sc) { String CLASS_NAME1 = 'Ru_Actual__c'; try { ...
2
votes
1answer
7k views

How to bypass Validation rules when running apex class?

We have a managed package install in our org. When I create an opportunity, at a certain stage, I need to create a record of that managed package. For this we define validation rule for certain stages....
0
votes
1answer
188 views

Issue Deploying a Trigger

I am pretty new to Apex triggers and Apex Class Tests but i have written and deployed a couple successfully so far. But i am having real problems with a new trigger that i have created. I have ...
3
votes
1answer
324 views

Testing future Callouts

I am trying to make a future callout sending email name etc from a trigger when a lead is created which is working. The problem is Testing. I am not sure how to go about making this work. I have been ...
0
votes
1answer
34 views

Old unchanged Test Method Fails during deployment of unrelated code

There are similar questions but they hold no answers and are not specific. Error Message / Test Failed during deployment of unrelated code: Test_Method_Test ThisTest System.ListException: List ...
0
votes
1answer
65 views

Test Class Having More Issues Setting Basic Dummy Info

I'm having issues with setting the dummy data as there are a lot of required fields on the system. I'm getting this error when attempting to create a dummy Marketing Source. And I apologize on the ...
1
vote
1answer
110 views

Apex Test Class Throwing Error

I have an apex test class that is not working due to not having an appointment tied to it. I'm not sure how I've messed up. I know this is a beyond easy fix but I've been looking at it for too long ...
3
votes
1answer
2k views

How to create Report (not report data) in Apex Test Class without using SeeAlldata=True?

Joint Report is not supported in lightning.So in our org we have an existing reports in which we pull the data from it and pass it to lightning components so that lightning we can show joint reports. ...
0
votes
1answer
85 views

DeReference Null object

I have a trigger that I need to deploy urgently to our org. The trigger works perfectly however running the test gives a null object error, I have created the object and assigned all the correct ...
5
votes
0answers
343 views

Difference between deploying user and System.runAs()

I have a weird situation where some test classes will deploy to Production only if the user deploying it has a specific keyword on their LastName - "TestMode, TestsEnabled". Updating my test classes ...
0
votes
2answers
248 views

getters/setters - unable to assign a value from test

Given the test code below the property originalOrderAmount is null but it has to be 100. What am I doing wrong? Controller: @TestVisible public Decimal originalOrderAmount { private set {...
1
vote
1answer
32 views

Stale Subscriber Trigger? Tests Only Pass When Trigger Body Modified Most Recently

Getting started with Platform Events has been a bit of a rocky start for me. At least, getting any of the Unit Tests to pass consistently. The feature itself has worked every bit as well as I hoped, ...
2
votes
1answer
210 views

MocksApex - behaviour verification

I am using the ApexMocks framework and I am having the following error message: Class.MockTest.testBehavior: line 13, column 1 11:53:56.3 (10709808)|FATAL_ERROR|System.NullPointerException: ...
0
votes
1answer
231 views

Controller Extension Test Help?

I will start out by apologizing for being a total n00b but, I need some help increasing my code coverage ASAP. Currently I am at 73%... so close!! Any help/advice/anything is a huge help! Thank You! ...
0
votes
1answer
98 views

Test class code coverage error

As of now test class code coverage 85%, but when we are validating the chageset getting 0% code coverage error saying ` STANDARD_PRICE_NOT_DEFINED No standard price defined for this product. ...
0
votes
0answers
157 views

On post request- System.CalloutException: . Please commit or rollback before calling out"?

public with sharing class CalloutHandler { @future (callout=true) public static void createAccount(String id) { Http http = new Http(); HttpRequest req = new HttpRequest(); req.setHeader('...
1
vote
0answers
158 views

create a mock class for callout in managed package [duplicate]

we have a managed package and the function call_out is making a http request. In the package we can use this code to create a test for it: Test.startTest(); Test.setMock(HttpCalloutMock.class,...
0
votes
1answer
2k views

How to Cover apexpages.currentpage().geturl()

In my constructor I'm declaring as pagenm = ApexPages.currentPage().getUrl().substringbetween('apex/','?'); And in the action button I'm writing these lines if(pagenm = 'Page1'){ // some code ...
0
votes
0answers
713 views

Permission Set in Test Class

I have a test class which fails when the Deferred Sharing is on. Because the test data created by the admin user is not seen by another user . and I get insufficient privileges error when i run as new ...
0
votes
0answers
1k views

Apex job is already scheduled for execution

Hi I am getting apex batch already scheduled error while running test class. I don't know where i am going wrong. I am calling batch class from schedule class. Apex Class global class ...
0
votes
1answer
154 views

Unable to create test class for vfp controller get method - new to apex [closed]

I am new to apex and salesforce development, would like to create a test method for the controller below, however I am unable to get better results than 30% coverage and even the getter does not go ...
0
votes
1answer
639 views

Trouble with inserting an user in test class

I am trying to insert a profile called "Vendor Partner Portal" for a user in my test class. When I run the tests I am getting an error message saying System.DmlException: Insert failed. First ...
3
votes
1answer
491 views

attempt to de-reference null object in test class

I'm attempting to write a test method for my constructor and when I get to a method in my non-test class where I'm assigning a value to the object passed I get a "attempt to de-reference null object ...
-1
votes
1answer
210 views

Test class failure?

Acc.name=(Acc.name).toUppercase(); // Here getting account name and make it uppercase Exaccounts.add(Acc.name); // here storing account name.
1
vote
1answer
315 views

Apextest: Calling addFields, Fields needed in Extension

I'm trying to write a test class for my controller extension. In this extension I used addFields to add custom fields which i already filter with !Test.isRunningTest(), so it wont cause an error ...
0
votes
1answer
268 views

Strange test class behavior during validate [closed]

I had issue with deploying some changes to prod. First please note that this contain many changes in some triggers/classes, therefore don't sure if it'll help to post here all the relevant code and ...
0
votes
1answer
52 views

Test coverage improvement

I have written a trigger on Email message object and a test class, where its code coverage is not even 1%, please suggest me the best way - if am wrong. Trigger : trigger CloneClosedCase on ...