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
2
votes
1answer
4k views

test fails because of TestMethod do not support getContent call

My below test fails because of Run Failures: TestRangehoodObjectionSheet.RangehoodObjectionSheetTest Methods defined as TestMethod do not support getContent call. I added the Blob thinking it might ...
16
votes
4answers
7k views

How to handle installed Managed Packages failing tests?

I have several AppExchange apps installed that are failing tests. What is the recommended approach to resolving this? Are tests run when a new package is installed? Is there a way to determine what is ...
3
votes
2answers
1k views

Case assignment rule is always executed in the test class

No matter what to do, the case is always assigned by the assignment rule!! You can try the scenario and code which are attached in the post. But, I have tried to execute the code in the developer ...
3
votes
3answers
606 views

Else part in Test Class

how do I cover the else part in this test class public with sharing class RecUtility { public static boolean flag=true; public static boolean runonce(){ if(flag){ flag=false; } else { ...
2
votes
2answers
4k views

How to test apex classes with Pagereference?

I'm struggling to test a class with pagereference. Following is the class... public with sharing class redirectOrderPartner{ public String currentRecordId {get;set;} public orders__c orderId {get;...
4
votes
2answers
3k views

INACTIVE_OWNER_OR_USER

I'm getting an error INACTIVE_OWNER_OR_USER, operation performed with inactive user, and I have been doing a lot of research and the cause that I have found for this is its attempting to assign a my ...
1
vote
2answers
272 views

Cleared Code Coverage cache

How can I clear the code coverage and I'm stuck to 60% and regardless its not what test I write its not increasing but my question is: is there a way to flush the cache?
0
votes
2answers
79 views

Test Class - Error - Constructor not defined

Error - Constructor not defined: [PrepareSandboxPostCopy_Batch].() Test Class @isTest private class SandboxPostRefreshTestCase { static Testmethod void testSandboxPostCopyScript() { ...
17
votes
2answers
1k views

Test.setCreatedDate fails on note record created in test context

I'm trying to get a number of records inserted into the database sometime in the past, to allow for a cleanup batch to have proper test coverage. I can use Test.setCreatedDate on the account I'm ...
1
vote
2answers
16k views

System.NullPointerException: Argument cannot be null

Im getting the error 'System.NullPointerException: Argument cannot be null' when I run my test class, in the below test method. /* * update a existing report */ static testMethod void ...
1
vote
1answer
289 views

Test Class for HTTP Callout failing

This may sound repititve question. But the error incurs after following multiple links found like: here and here. The controller: public with sharing class SFLoginCtrlr { public static ...
0
votes
0answers
48 views

APEX Test Class: Round Robin Lead Distribution Model

The original question can be found here. However, as an overview, the code is responsible for assigning Leads to sales representatives with round-robin distribution based on the Queue that is assigned ...
6
votes
1answer
12k views

Assign a case to a queue in Apex (Test class)

I'm sure this must be quite possible, and probably easy. I need to create a test method in which part of the scenario is that for when a Case is assigned to a Queue. I have successfully tested all my ...
4
votes
2answers
4k views

Test code for the new standard Order object

The last line insert ordPd causes exception: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Price Book Not Set on Order: [] All lines before the ...
3
votes
2answers
146 views

How is it possible for @TestSetup to effect test result?

While refactoring a test to make it more consistent with the style of our other tests, a colleague came upon something really weird. The original test created the test account in @TestSetup, like so: ...
3
votes
1answer
290 views

Describe call inconsistent in test class

In the Apex class below (executed in a client org), testA() passes while testB() fails. The failure is an assertion error from the ServiceLayer constructor. /* SF API 33 */ /* PKG version 1.55 */ ...
2
votes
0answers
234 views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY on Communities Change Username Page Test

I created a visualforce page for Communities users to update their username and email. In real life the page works fine, logging in as a Community user I can update my username and email. However, I ...
1
vote
1answer
752 views

Delete failed exception when creating test data in an @TestSetup method

I'm trying to create an @TestSetup method for my test class, but I'm getting an exception that makes no sense to me whatsoever and I have no idea how to get past it. Consider the code: @TestSetup ...
1
vote
4answers
1k views

Low code coverage, when production and new test class to deploy are over 80%?

I am having an issue, for the last couple of days and I dont know how to fix it. I have run all the test classes in production, when I open my developer console, the overall code coverage is 79% (of ...
1
vote
1answer
2k views

picklist value not recognized in the test

When trying the test class for the related picklist value in a Quote field i get the following message: System.DmlException: Insert failed. First exception on row 0; first error: ...
1
vote
1answer
538 views

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Lead.ConvertedContactId [closed]

I'm writing a test class, but line 14, constantly throws an error when I'm trying to create test Lead objects. Here's my code and the error is the subject line of this post. @isTest (SeeAllData=...
0
votes
1answer
195 views

Social Sign On for Salesforce Reg Handler Class and Test Class-System.NullPointerException: Attempt to de-reference a null object

My org is setting up social sign on with Google and I am running into an error I have never seen before: System.NullPointerException: Attempt to de-reference a null object Does anyone know a ...
0
votes
2answers
43 views

line 20:29 no viable alternative at character ' '

Hi Salesforce stack exchange. I am a newbie when it comes to apex, and struggling with a particular issues. I'm having created a simple test Utility Class (using examples online). The utility class ...
0
votes
1answer
619 views

Test method not passing for duplicate trigger which checks for duplicate email (error : System.AssertException: Assertion Failed)

hi this is my trigger to test duplicate between two email address which is working fine and also it allows duplicate if the checkbox "allow_duplicate__c" is selected, but there is a problem with test ...
0
votes
1answer
130 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
0answers
138 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('...
0
votes
1answer
228 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 ...