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
1
vote
3answers
746 views

How to instantiate a BatchableContext

I'm writing a Test class for a method for start function of batch Class start(Database.BatchableContext BC) but I don't know what I have to pass as parameter, because start(new Database....
0
votes
2answers
230 views

Ghost Inspector test automation and varification Code

I have a Apex page that I need to test using ghost Inspector. I used chrome Extension to record my screen from the login section. The problem i am having is that ghost inspector is failing after login ...
1
vote
1answer
414 views

LastViewedDate in test class

I think i have run into a peculiar bug. There are two ways to run test code: 1) Setup -> Inbound change sets -> Select change set -> Validate button or deploy button. 2) Setup -> Develop -> Apex ...
0
votes
1answer
614 views

how to write test class for methods with API calls?

class :- facebook_API public class facebook_API { public static HttpResponse getpermissionresponse(String accesstoken) { Http http =new Http(); String flagpermit ='true'; HttpRequest req ...
0
votes
1answer
30 views

Writing Test Coverage for Else

I am struggling with covering this if-else conditional. public void pullIDAnalyticsReportAPEX() { crsUpdate(); generateJSON(); } public String generateJSON() { currentPgId = ApexPages....
1
vote
2answers
142 views

test class error - attempt to de-reference a null object Trigger using oldmap

I am receiving an Error in my Test class, but am unsure of the reason why. Here is the Error: Exception: Update failed. First exception on row 0 with id a0i4C000000HfieQAC; first error: ...
1
vote
1answer
32 views

Recall a field in a test class

I have a field in an if condition and I want to validate it in my test method. This is the if method in my class: if ( String.isNotBlank(account.Phone__c) I have a method in my test class in which ...
3
votes
2answers
132 views

Why is my task trigger test failing

I have a task trigger which updates two custom fields on the Account object : Last_Call_Date and Last_Meeting_Date. I have tried logging a task in sandbox and it updates the fields correctly. However,...
0
votes
1answer
36 views

Test Method Fails

I am encountering this kind of error: System.DmlException: Update failed. First exception on row 0 with id [Some Id]; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateBlockB: execution ...
0
votes
1answer
24 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)...
1
vote
1answer
177 views

Test class failure on Case Object

I'm blocked in creating a Record for PartnerNetworkConnection.I'm getting an error like QueryException: List has no rows for assignment to SObject. Stack Trace: Class.caseForward.forward: line ...
0
votes
2answers
2k views

Why is the DUPLICATE_USERNAME

We have a test class failing with the following error message: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_USERNAME, Duplicate Username.The username ...
0
votes
3answers
78 views

apex test class fails to get rows, why is that?

i wrote a test class that is working fine in my sandbox enviroment, but for some reason on production it fails nad gives me the message: "System.QueryException: List has no rows for assignment to ...
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
718 views

Test class for Exception and Messaging.SingleEmailMessage

I wrote a batch class that runs whenever a new sandbox is being refreshed. it takes all the contacts' email addresses and changes them from user@gmail.com to user@example.com. In addition, it checks ...
6
votes
1answer
4k views

Calling addFields in Extension class works on page, fails in test class

I've got a class which acts as a controller extension. The class is designed to add a number of fields to the StandardController so a component used on the page can dynamically access some fields. ...
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: ...
0
votes
1answer
427 views

Code coverage warning: Test coverage of selected Apex Class is 40%, at least 75% test coverage is required

All of test classes have code coverage more than 90% in lower environment but when our admin move all test classes and apex class to Production.It display warning message mentioned in heading and also ...
-1
votes
1answer
43 views

Test Coverage Help- SOQL Query

I am having difficulty testing a SOQL query. I am not allowed to put hard coded data in the test. So far my test coverage is very basic but should cover a lot, it looks like: static testMethod void ...
-3
votes
1answer
443 views

what happends when test classes fail at deployment time?

Suppose I have some Apex Classes and 50 test classes. Out of fifty test classes one test class fails. What happens at deployment time?
1
vote
1answer
779 views

ENTITY_IS_LOCKED exception during test class [duplicate]

I'm getting this weird exception during test class. The test class is related to Contract object, and I'm almost sure that nothing was changed lately regarding. Also I searched my whole code, to find ...
-4
votes
2answers
210 views

test class is not working [closed]

I worte the below helper class and it is working perfectly, but I have an issue with the deployment because of the test class public class CESExtension { public CES__c CES; public opportunity ...
0
votes
1answer
23 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 ...
2
votes
1answer
74 views

Sandbox to Prod- Test Data

I am having a hard time wrapping my head around a concept. I write a query that pulls out data from salesforce and sends it to a web service. The webservice sends me back data for a report. This ...
0
votes
1answer
30 views

Test Error- Changing from List to Id - List has no rows for assignment to SObject

In my test class I have a query: Id oppId = [SELECT Opportunity__c FROM Credit_Review__c LIMIT 1].Opportunity__c; when I use query editor: SELECT Opportunity__c FROM Credit_Review__c LIMIT 1 I get ...
0
votes
0answers
274 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 ...
2
votes
1answer
910 views

use testsetup for common methods in test class

As per my understanding and salesforce documentation, class annotated with @isTest should contain "only test methods". But there are some situations where we might need to have utility methods and ...
0
votes
0answers
40 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
2answers
352 views

Help with CreateDate and Test.isRunningTest

i had a post but accidentally deleted my account -hits Head- the original post contained my question of how do i test createdDate.hour() if i cannot modify the createddate even to test an account ...
0
votes
1answer
102 views

Test Class for Trigger not providing full coverage

I am having problems creating a test class to cover a small amount of code, but my test is not proving full coverage. Trigger trigger deletedOppLineItem_Tr on OpportunityLineItem (before delete) { ...
3
votes
1answer
4k views

How to catch a validation error exception in an apex test class

I have a validation rule that checks if the user tries to enter a Quantity > 100. If so, the validation returns an error. I'm trying to to catch the validation exception, but it seems like the ...
0
votes
1answer
80 views

Why won't this Test Class provide code coverage?

Edit Sept 28th 2016 Thank you all for the feedback! I have a lot of reading to do and I will be marking this as answered. Please see... Customer Community User (Non-Plus) Sharing Set Access not ...
1
vote
2answers
136 views

Test Error: JSON2Apex method does not exist

Error: Method does not exist or incorrect signature: JSON2Apex.parse(String) I used https://json2apex.herokuapp.com/. I got back APEX and a test class that should work. I am getting the above ...
-3
votes
1answer
37 views

Please suggest a test class to cover the below part of my code

PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e'); Map<String, String> m = p.getParameters(); m.putAll(ApexPages....
0
votes
3answers
618 views

A flow trigger failed to execute the flow with version ID xxxx

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to ...
0
votes
0answers
193 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
1answer
77 views

Contact Record - System.QueryException: List has no rows for assignment to SObject

Task a=new Task(); a.whatid=Acc.id; a.Status='Communication Sent'; a.Action__c='Auto Execute'; a.Adhoc_Communication__c=True; a.Email_Address__c='henry@gamil.com'; a.Encrypted_Reference_Number__c= ...
0
votes
1answer
2k views

System.AssertException: Assertion Failed: Expected: 2, Actual: 3

Earlier this is working with 3 but due to few modifications to this class, Now it is not working. What would be the problem if i change like System.assertEquals(lAccrSaleConShare.size(), 2);
1
vote
1answer
439 views

Unable to insert group during tests - “Group Already Exists” with SeeAllData=False

Create a class to automatically add user to chatter groups. I wrote a test class to cover the code. The class is working fine and covering code if I add SeeAllData=true. Issue: If I remove seeAllData=...
0
votes
1answer
123 views

Error Message : System.DmlException when tring to insert an record in Test class [duplicate]

My test is failing when I am trying to insert an record in test class. I am not sure why it is happening. Can someone help. The error message I get is: System.DmlException: Insert failed. First ...
3
votes
2answers
2k views

Unable to test the result of batch class execution

I am testing a batch file which just changes the field value of records in scope and updates them: global class AbatchClass implements Database.Batchable<sObject>{ global String query; ...
1
vote
1answer
3k views

How to fix this Compile Error: Expression must be a list Type

First, let me say that I did not write most of the code below. I am trying to deploy additional Apex code and this code, written by my predecessor, is failing Apex tests when I try to deploy my change ...
0
votes
1answer
42 views

Best way to create test methods and avoid soql limits exception

I have an apex controller which has some really bad code doing a lot of unwanted soqls based on conditions. My current test class has a test method which executes all the apex controller methods in ...
1
vote
1answer
754 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 ...
2
votes
1answer
267 views

Rolling Limit applies for Test classes?

I am using a test class and getting the error: System.UnexpectedException: ContentPublication Limit exceeded. This is a rolling 24 hour limit. Below is the code: @IsTest private class ...
0
votes
1answer
404 views

Sucessful test on Sandbox failing on deploy to production

I'm deploying a simple class+test from sandbox to production. The test is successful on test but fails on deploy as stated on the title. I've checked validation rules, process builder flows and ...
0
votes
2answers
59 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 ...
4
votes
1answer
114 views

Unit test error - You have uncommitted work pending

I get an error in my apex test class You have uncommitted work pending I am aware of the Salesforce limitation in an http callout, we can't perform any DML operations before we send an http callout....
0
votes
1answer
3k views

System.AssertException: Assertion Failed: Same value

This is related to Lightning Specialist Superbadge step 6 - Automate fulfillment cancellation actions. The task is when fulfillment is Cancelled, the related OpportunityLineItem unitprice (i.e., ...
3
votes
3answers
609 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 { ...