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
0answers
370 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
408 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
555 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
141 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
5k 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
154 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
272 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
32 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
55 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
108 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 ...
1
vote
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
76 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
334 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
218 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
30 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
194 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
183 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
93 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
131 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
122 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
590 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
124 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
473 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
420 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
178 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
253 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
220 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
51 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 ...
0
votes
2answers
856 views

Unable to cover testclass on feedItem

Written a testclass on feeditem, but no luck(its 0%) - not sure about the mistake in my code. Please do help me out and de needful. Trigger : trigger RestrictFilesOnFeedItems on FeedItem (after ...
0
votes
1answer
244 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 ...
1
vote
0answers
75 views

Test method fails only when being run synchronously from the Dev Console [duplicate]

My test method will pass when "Always Run Ayschronously" is checked. Test method will pass when being run through the UI. Test method will pass when being deployed via ANT with testLevel="...
1
vote
1answer
120 views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY using both standard and custom objects and when profile is not given “ModifyAll”

I'm using objects Opportunity, OpportunityTeamMember, User, Opportunity_Team_Member, and Employee__c. For me to create a member, i will choose an employee, checks if the email has match with user ...
1
vote
1answer
65 views

Test class for controller is failing is production as SOQL on Period is not returning any records [closed]

I have written a test class for a controller which is running in Sandbox, but failing in Production with the following Exception: System.QueryException: List has no rows for assignment to SObject ...
3
votes
0answers
298 views

Test passes when run alone; fails when run with other methods in the same class

I've got a test that passes when run by itself, but fails when run alongside another method in the same class. No changes were made between test runs, and I have made sure to select Disable Parallel ...
0
votes
1answer
239 views

INVALID_CROSS_REFERENCE_KEY

When we are running the test class getting below error: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, You can't assign or unassign this ...
0
votes
1answer
69 views

Changeset updates to Class and Test Class fails, old Test running for new Class

I have a class that required modifications, therefore the test class changed as well. Pretty simple stuff, new test passes in dev sandbox, changeset promoted from dev to a full copy staging org, test ...
0
votes
1answer
431 views

Error using Database.Savepoint in Apex Test class

I have a test class with the following function in it: @isTest private static void testDequeue() { ... // a LOT of setup code here Test.startTest(); Savepoint sp = Database.setSavepoint()...
8
votes
1answer
351 views

Custom settings and parallel test execution

I have a bunch of unit tests in which I'm updating my custom settings object to test certain workflows. This causes an UNABLE_TO_LOCK_ROW exception since multiple tests are updating the values ...
1
vote
3answers
703 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
223 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
392 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
574 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
141 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
127 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)...