Questions tagged [apextestrunresult]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
65 views

Test Code Coverage - Delete DML catch block

We have implemented one method using Apex for delete some records under the class which is without sharing. In the method, first we are retrieving the list of the records(which needs to be deleted) ...
samarpita saha's user avatar
0 votes
0 answers
36 views

Delete in a Apex Test Class

I have this apex test class, the only problem with this is delete isn't being covered when running test. Is there something missing from this? @isTest(seeAllData=false) public class ...
Jaemy Malik's user avatar
0 votes
0 answers
32 views

System.QueryException: List has no rows for assignment to SObject - Apex Class Test Failure

I'm trying to put a deployment into one of our instances and am getting the above error when the Apex Class Test is running. I can't work out for the life of me why it's not working, but suspect that ...
Lyndsay Brown's user avatar
-3 votes
1 answer
52 views

Apex test class not working and fails

I have the following apex class: public with sharing class TT_DisplayRelatedOpportunities { @AuraEnabled(cacheable=true) public static List<Opportunity> getOppList(String recordId) {...
Marjan's user avatar
  • 15
0 votes
1 answer
77 views

I want to cover catch block of main class to have 100% code coverage. Can't seem to throw exception. If anyone can help

I am able to cover try block of my main class, but failing to do the same for catch block. Here's the given code for my current test class and Main Class. Controller Class- public with sharing class ...
SF Learner's user avatar
0 votes
0 answers
99 views

Apex Test - either Invalid conversion from runtime type String to Date or Invalid Date

I am trying to test code that takes a URL string and maps it into fields and values. I am having trouble with the date and date/time fields. In the following code I get the error message "Invalid ...
Jonathan Crow's user avatar
0 votes
0 answers
120 views

Understanding the proper response for a mock callout

I have code that I am trying to test that includes a getcontent() request. I know I need to create a mock callout for this, however I don't know what the proper response should be. How can I find out ...
Jonathan Crow's user avatar
0 votes
1 answer
57 views

Issue : "No content to map to Object due to end of input" in test classes

I am getting Issue in test class. I am not able to cover the test coverage of responsebody When I debug it show the "common.apex.runtime.impl.ExecutionException: No content to map to Object due ...
Abhi's user avatar
  • 1
0 votes
0 answers
39 views

Apex Failed Test Run: Method does not exist or incorrect signature

I have a class with the function: public static void updateTargetAmount(Id targetId, String customFieldApiName){...} In my Testclass i handover the 2 parameters: TargetHelper.updateTargetAmount(...
Benjamin's user avatar
0 votes
1 answer
340 views

Apex Test for LightningSelfRegisterController

I have the LightningSelfRegisterController and LightningSelfRegisterControllerTest that were prebuilt in SF. The test only covers the class at something like 72%. I need to get this to 90% and am ...
Jonathan Crow's user avatar
1 vote
1 answer
275 views

Test Code coverage for LightningLoginFormController

The prebuilt class LightningLoginFormController has a try/catch block that I am trying to cover in test. @AuraEnabled public static String login(String username, String password, String startUrl) { ...
Jonathan Crow's user avatar
-2 votes
1 answer
235 views

Apex Test for setExperienceId

I have a class ForgotUserPassword that uses a community page to set the Experience ID. When I try to build a test class for the setExperienceId, I get an error message saying that “This method can be ...
Jonathan Crow's user avatar
0 votes
2 answers
191 views

Apex test class method not working

I have the following method in my apex class: @testVisible private static Custon_Object_Case__c getExistingRecord(Messaging.InboundEmail email){ List<String> referenceId = email.references; ...
Marjan's user avatar
  • 15
0 votes
2 answers
28 views

Problem with Test Class If/Else string is null

I have the following class that I need to cover. It takes the search value from the VF Page and creates a list based on the entered value. public with sharing class ServiceConsoleFastLinksController { ...
Jonathan Crow's user avatar
0 votes
1 answer
68 views

Asking for License to assign a permission set to a user in test class

Hi all i am assigning a permission set to a user below the code " public static void assignPermissionSetsToUser(Id userId, Set<String> permissionSets) { List<...
Vishal's user avatar
  • 1
0 votes
1 answer
145 views

System.AssertException: Assertion Failed: Expected: Invalid File type, Please upload csv file., Actual :Script-thrown exception

Test class @isTest public class Participants2Test { @testSetup private static void testSetup(){ TestUtility.setup(); } @isTest static void testCsvFileRead() { // ...
YETURU CHENCHU's user avatar
0 votes
1 answer
40 views

APEX Multiple From in Database.getQueryLocator

I have a class (inherited) that sets the StandardSetController through a Database.getQueryLocator as follows: ApexPages.StandardSetController setCon = new ApexPages.StandardSetController(Database....
Jonathan Crow's user avatar
0 votes
1 answer
14 views

Help with Testing Database.Batchable

I have a class with the following: global with sharing class MS_Batch_Delete implements Database.Batchable<sObject>{ global final List<MS__c> mss; global MS_Batch_Delete( ...
Jonathan Crow's user avatar
1 vote
1 answer
45 views

What does this do? Throw new MS_Exception

I have (inherited) a class MS_exception that is this: public with sharing class MS_Exception extends Exception { } It has zero code coverage. Does it actually do anything? Do I need to cover it? The ...
Jonathan Crow's user avatar
0 votes
0 answers
60 views

Testing for Log Messages

I am writing a test class for a class that is mostly covered. But the part that isn't covered is this: public static void logException(Exception e) { logException(e, ''); } public static void ...
Jonathan Crow's user avatar
1 vote
1 answer
33 views

Apex Testing Object Data

I have a class with the code below that I am trying to test. I am still very new to Apex and not sure I understand what I am supposed to do with the "(Object data)" part. I tried testing by ...
Jonathan Crow's user avatar
0 votes
1 answer
88 views

Test class for records owned by System User

I have batch job class which fetches ServiceAppointment where Owner.Name = 'System User' in it's Database.QueryLocator start method. global class CancelDuplicateSaBatchClass implements Database....
Ravi's user avatar
  • 1
0 votes
0 answers
101 views

Inserting KimbleOne Event through Apex

I am trying to test Apex code that was developed to provide a @RestResource for Kimble Event information. In order to test it I either need to insert the event through Apex or us SeeAllData=true. I ...
Jonathan Crow's user avatar
2 votes
1 answer
125 views

test-result-codecoverage.json with more than 10k coverage items

We have high number of test methods. After running all test cases using sfdx force:apex:test:run test-result-codecoverage.json doesn't include all classes, it includes only 25% of classes. Is there a ...
Ashish Narang's user avatar
0 votes
1 answer
71 views

Trying to Load Data for RecentlyViewed but get error message "Required fields are missing: [OwnerType]"

I have a line of code in my test class: List<sObject> newRecentlyViewed = Test.loadData(RecentlyViewed.sObjectType, 'MyRecentlyViewedData'); The csv I uploaded to the static resource ...
Jonathan Crow's user avatar
-1 votes
2 answers
102 views

Cover StandardSetController in Apex Test

I have the following class and text class. The test class covers the class at 90% but doesn't seem to do anything or test anything. Any idea what I am doing wrong? public with sharing class ...
Jonathan Crow's user avatar
1 vote
1 answer
46 views

Apex Test Error - Constructor not defined

I am still new to Apex testing and am trying to build a test class on the following, but keep running into the error message “Constructor not defined: [MyNewCaseListController].(ApexPages....
Jonathan Crow's user avatar
1 vote
1 answer
70 views

Apex Test - Instantiate new Controller

I am trying to instantiate a new controller. But every syntax I have tried shows an error. Here is my code: Class: public class MyNewCaseController { public string filterId {get; set;} ...
Jonathan Crow's user avatar
-2 votes
1 answer
36 views

Test running issues [closed]

Tried running the test for the first time and seems I am doing something wrong can someone give me a hint? I saved it before running the code but the star never disappeared
K2Ardash's user avatar
-1 votes
1 answer
529 views

Does running all tests in an org impact actual real functionality? Should I not run all tests in production daily?

For years I was under the assumption that running all tests in an org does not impact actual functionality. At most, it may somewhat impact performance... Every night I run all tests in our UAT ...
Ryan Werner's user avatar
0 votes
1 answer
76 views

Apex test class for Standard Controller extensions - Test problem

:) I am writing test class for controller extensions, but I get the error: System.TypeException: Invalid conversion from runtime type Asset to Account. Can you please look at my code, and tell me what ...
ApexNewbie's user avatar
-3 votes
1 answer
741 views

How can I fix the errors in this Apex Test Class?

I installed an app from Salesforce Labs into my production org and later found out that there are errors in the test class. Now these errors are preventing me from deploying a different project, so I ...
NickG's user avatar
  • 3
1 vote
1 answer
1k views

Debug Test and Debug All Tests for apex unit tests in VSCodedx

Does anyone have a link to the official documentation on this new feature added to VSCode-dx? Also, any tips on using this feature would be appreciated. What I've tried so far: I've tried the feature ...
Bahman.A's user avatar
  • 808
-3 votes
1 answer
52 views

test classes fail after updating a fields length and its datatype [closed]

Was given a task to update a fields data type and its length, I commented certain parts of the code to do the change as it mentioned the field was referenced in the Apex classes. After the update ...
sumchans's user avatar
  • 641
2 votes
1 answer
195 views

Deployment / Validation apex test results

Does anyone know where the test results (especially runtime) are stored for tests that are run during a validation/deployment ? I know the objects where the test results are but how do they relate to ...
jani_r's user avatar
  • 123
0 votes
1 answer
541 views

Change Set Deployment - Code coverage failure

I am sorry if this has been answered here before, I was not able to find an answer. I made a small modification[changed an if condition, no new lines added or removed] to one of the apex classes in ...
sumchans's user avatar
  • 641
0 votes
1 answer
520 views

Test Coverage Issue with Site.getSiteId()

I am unable to cover the below function in test class as siteId is always returned null Id siteId = Site.getSiteId(); if (siteId != null) { //Community user logic -- THIS IS THE PART THAT IS NOT ...
Abhijith E's user avatar
1 vote
0 answers
602 views

Error when trying to translate Knowledge Articles in a test class

I have a test class in which I'm trying to translate Knowledge Articles into Spanish. Default language is English. If you were to do this from Salesforce UI, you have to publish each version ...
Aryansh04's user avatar
  • 282
0 votes
1 answer
113 views

Refactoring Help for main class or test code coverage

I'm trying to refactor the following code.I'm trying to figure out how to refactor this code OR if anyone have a good way to do code coverage for this. My issue is that, in dev, the code coverage is ...
jojopogi's user avatar
  • 484
0 votes
1 answer
5k views

DEBUG|Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field

I have a record type picklist on Case object. When I create case via email-to-case that works fine without any issue(I have some APEX code related to that) Issue: The problem is when I write test ...
Kamran Jabbar's user avatar
0 votes
1 answer
350 views

Test class not covering my batch

I'm new to batch scripts. In my apex batch My start method will send records to execute method based on input given in custom label. I have created a test class and I'm not sure my execute method is ...
Vignesh S's user avatar
0 votes
1 answer
521 views

How to Schedule Run all apex tests on daily basis

How to Schedule Run all apex tests on a daily basis? Currently, we are performing it manually is there any way we can automate it?
Spande's user avatar
  • 61
1 vote
1 answer
258 views

Why code coverage result is different when we run it from CLI and Salesforce

We are working on SonarQube code coverage, We are using Salesforce CLI for generating the code coverage result and we are importing that result in the SonarQube. We see that there is a difference in ...
Spande's user avatar
  • 61
0 votes
1 answer
999 views

test class for wrapper class in apex

public with sharing class ResponseWrapper{ public String Id; public String Time; public String lobType; public String businessContextId; public Information[] document; public ...
garvita asthana's user avatar
1 vote
1 answer
51 views

Missing ApexTestRunResult Data

Yesterday we had 10-11 records and today just 2. This is what I did: Check recycle bin and using All Data Check Bulk API delete capable processes and users Check connected apps. DataLoader.io SSO ...
kratos's user avatar
  • 521
1 vote
0 answers
735 views

How to delete a Person Account in Apex Test

I have difficulty to delete Person Account(PA) in Apex test. The reason is that I cannot figure out how to disable the associated user record. The org has Salesforce SSO and PA feature enabled. Here ...
Xi Xiao's user avatar
  • 863
-3 votes
1 answer
3k views

Unable to cover test class for history object [duplicate]

Here is my test class public class BoothChangeReportCtrl { @auraEnabled public static List<BoothChangeDetail> getBoothChangeData(){ List<BoothChangeDetail> ...
RAHUL KUMAR's user avatar
0 votes
1 answer
289 views

How can i test inside for loop apex test? [duplicate]

public static List<priceBookEntryWrapper> searchproduct(String sampleId, String seriesValue, list<string> gradeValues){ system.debug('seriesValue->->->->->->->->...
Shubham Gupta's user avatar
1 vote
1 answer
449 views

Too many SOQL queries error encountered when running the class in Sandbox but not in Production

I have experienced a bunch of test classes fail to pass in a Sandbox, but execute fine in Production. Has anyone some good tips on what look out specifically? I think the code itself is not ...
Endrit Sino's user avatar
0 votes
1 answer
206 views

unit testing - if record is created with certain record type

I have a function createWithRecordTypeIfExists(String recordType). Its logic goes like this: Check whether a record type for this object exists in the org. If yes, create a new record with this ...
Xi Xiao's user avatar
  • 863