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.

88 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
183 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 ...
0
votes
0answers
559 views

How to create a correct test for knowledge articles?

I'm creating a package with a simple Apex class that retrieves info about knowledge article (Lighting Knowledge). However, I'm having an issue with a test. When installing the package via installation ...
0
votes
0answers
104 views

Unable to write BestCommentId on FeedItem in test class

I am trying to write a test class to test an Apex class that uses FeedItem object. The Apex class checks if the FeedItem record has a BestCommentId and does some actions. A snippet of the test data ...
0
votes
1answer
914 views

How to solve this deployment errors (Variable does not exist: isReadOnly)?

Trying to deploy package (big one) to a new org but all the tests failed with very weird errors: 1)line -1, column -1: Dependent class is invalid and needs recompilation: Class ClassName : Variable ...
0
votes
0answers
52 views

Test Classes: MIXED_DML_OPERATION

Via Process Builder, Is there anything I can do in my process that could stop this from occurring? Error Message: System.EmailException: SendEmail failed. First exception on row 0; first error: ...
0
votes
1answer
44 views

Test Method for Case Insert from Trigger

I have a trigger that fires when an Opportunity is Closed Won, has OpportunityLineItems and those OppLineItems relate to a specific Product. The firing of the trigger creates a Case Record based on ...
0
votes
1answer
988 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 ...
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
0answers
111 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
1answer
38 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
101 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
179 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
0answers
1k 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
258 views

Apex Test Results in Eclipse not reporting correctly

I'm using (the apparent latest because there's no updates ATM) Eclipse Neon v4.6.3 Force.com IDE v38.0 When I run my Apex unit tests, I only get a green checkbox in a single item in the test results ...
0
votes
1answer
25 views

Increase a Test Class code

i have an issue, i want to increase in my test class this code: if(!String.isBlank(account.A_Field_Picklist__c) && !ClassOfCostants.NotValutable.equalsIgnoreCase(account.A_Field_Picklist__c)...
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
24 views

Test Class Help Needed. Assertion is failing, and I can not figure out the cause

Below is my test class and class that is to be tested against. I am getting an assertion fail on line 105 (Well all of the assertion lines on 104, 105 and 106 of method tm2. I can not figure out why ...
0
votes
0answers
276 views

How can I extend test class coverage to exception (`catch`) blocks?

I am calling a function (that is defined in some other helper class) in a controller that will populate a list. Due to some problem in that other helper class, it is not returning the data, it just ...
0
votes
0answers
57 views

Opportunity product search testclass is getting assertion error

I am getting error while running Apex Test Execution System.AssertException: Assertion Failed Class.opportunityProductEntryTests.theTests: line 80, column 1 Below is the test class @istest(...
0
votes
0answers
266 views

Test Failure: System.ListException List Index Out of Bounds: 1

I am encountering the below error when running my preliminary test code for my custom controller. I do plan to add some system.assert(); to the code, but would like to get the method to run first. ...
0
votes
2answers
69 views

How do I unit test if a user cannot update a field

I added a new method on a trigger that before update on a lead, checks to see if the user is of a specific profile. If they are, it renders an error. It works fine, but how can I write a unit test for ...
0
votes
0answers
572 views

INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

I am facing this error when i create an account & contact by calling another test class: Apex Class:(My code starts with else block) public void beforeUpdate(SObject oldSo, SObject so) { ....
0
votes
2answers
310 views

how to avoid 101 error in test class

I have written the following nested query: List<Account> accountList = [SELECT Id, Name,(Select Id,Name,Inactive__c FROM Contacts WHERE AccountId =:accountToInactive.Id AND Inactive__c=false),(...
0
votes
1answer
271 views

Test class not covering code in batch apex

HI I created a batch apex but my test class is not covering the entire code, not sure where i am going wrong. Looks like query in start method is not returning any test records which i created. Please ...
0
votes
0answers
2k views

Test Class Failure : DUPLICATE_VALUE, duplicate value found: Unique_Record_ID__c duplicates value on record with id:

I am facing an issue with a test class. Getting the following error (System.DmlException: Upsert failed. First exception on row 0 with id a0xuxuxuxuu..; first error: DUPLICATE_VALUE, duplicate ...
0
votes
0answers
222 views

System.Null pointer exception error on an empty line of code?

I am getting below error in a test class when I want to save another class. System.NullPointerException: Attempt to de-reference a null object at line 32 The problem is that I commented line 32, but ...
0
votes
1answer
129 views

Unit test for page reference

I had this pagereference method, My testmethod is static testMethod void testvalidate() { String userid = UserInfo.getUserId(); Map<String, String> QR = new Map<String, ...
0
votes
0answers
211 views

One or more Apex triggers lack test coverage. Add test coverage for the following

Upload Failed One or more Apex triggers lack test coverage. Add test coverage for the following triggers and upload again: EmployeeScheduleTrigger I have covered pretty much more than 75% of the ...
0
votes
0answers
360 views

Trigger to Populate a Lookup field on Opportunity

I have created a Trigger to auto populate a lookup field on Opportunity as that was not possible with a workflow and had to reference that field in Exact target as in Exact Target we can only refer ...
0
votes
0answers
257 views

System.NullPointerException: Attempt to de-reference a null object when creating Lead Object in Test Class

Getting this error when trying to run this test class: @isTest (SeeAllData=false) private class RL_Test_UpdateLeadType { @isTest static void test_method_one() { // Implement test code ...
0
votes
2answers
794 views

Validation rule and Managed Package

I have a Validation rule in ShippingPostalCode in Account Object. Validation rule check for US Standard format and field should be required. When I run runAllTest from Developer Console. Managed ...
0
votes
0answers
37 views

Test class assumption failing after 2 years

I have a test class that has been in production for nearly 2 years. It is mostly self contained including an XML string that is interpreted and then broken into the component parts and stored. Then we ...
0
votes
0answers
639 views

Deep Clone Test Class not finding newly created record

I have a deep clone class that is called from a VF page. The class executes perfectly, I just cannot get my test class to work properly. I'm trying to verify that the cloned record is created within ...
0
votes
0answers
66 views

Assertion Results Changing / Inconsistent Assertion Statements

Team, I have a VERY odd problem. When I observe the test results, through an assertion the results change each time the test is run. The result should be 4, so I have the following statement: ...
0
votes
1answer
127 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 ...
-1
votes
1answer
57 views

Test Class failing due to Mixed DML Operation Error on User

Error :- System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (...
-1
votes
2answers
944 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 ...

1
2