A unit test is code that is written and executed to test a specific portion/unit of source code. Unit tests are class methods with the testMethod modifier or @isTest annotation and are usually placed in separate test classes annotated with the @isTest annotation. Code that is executed by unit ...

learn more… | top users | synonyms (3)

2
votes
1answer
27 views

TEST : Http Callout Error

I was trying to test an apex class that uses some http callouts with HTTPMockRequest. When trying to run the Test class it gives me the following error: Methods defined as TestMethod do not ...
0
votes
1answer
17 views

How to write test case for catch in following method?i want to cover catch block in code coverage [on hold]

@RemoteAction public static List<Account> GetAccountOwnerEmail(String AccountId) { List<Account> lstAccount = new List<Account>(); String [] conFields = new ...
0
votes
0answers
15 views

Building Test Class for Custom Controller Extension for VisualCharting

I'm learning Visualforce/Apex from scratch. So far it works in the sandbox/trial developer edition but when trying to deploy it to production salesforce. There's requirement for testing class and I'm ...
-2
votes
0answers
25 views

Regarding SavePoint and Rollback [on hold]

I Want to Set the UserId=Null Throughout this full Request Process by Following Code RestRequest req100 = new RestRequest(); req100.requestURI = '-------'; req100.httpMethod = 'post'; ...
-1
votes
0answers
26 views

Concurrent Test for Apex Request Service

There are two active Portal users in salesforce Considered User 1 and User2 The Following Code: RestRequest req100 = new RestRequest(); ...
2
votes
1answer
23 views

Getting error in test class System callout exception

I am consuming webservice rest api(post method) in apex class using webservice static method.i wrote test class but i am getting System.CalloutException: You have uncommitted work pending. Please ...
0
votes
2answers
25 views

how can improve code coverage of this batch class..i m sending data of query still data is not sending in batch class

this is my main class global class BatchJobContractRetention implements Database.Batchable<sObject>,Schedulable{ public void execute(SchedulableContext sc) { ...
-4
votes
0answers
31 views

Regarding to Write a Test Class

@HttpPost global static String doPost() { RestRequest req = RestContext.request; RestResponse res = Restcontext.response; Blob body = req.requestBody; System.debug('Test:' + ...
-2
votes
0answers
28 views

Regarding Apex class and Test Class [duplicate]

@HttpPost global static String doPost() { RestRequest req = RestContext.request; RestResponse res = Restcontext.response; Blob body = req.requestBody; System.debug('Test:' + ...
0
votes
0answers
22 views

Update failed: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id

I have three test classes in my org which are not executing. For those three classes I'm facing same error. After analyzed three classes I'm having same problem with account. When i comment the ...
0
votes
0answers
33 views

HTTP Callout and DML after callout

I have a HTTPCallout class, whose response is captured and saved as a document or updated if that document already exists in database. I have separated the class so that the Callout is done in another ...
-2
votes
0answers
46 views

Regarding Apex class Execution [on hold]

I Have a Given Following Code for Apex Class @HttpPost global static String doPost() { RestRequest req = RestContext.request; RestResponse res = Restcontext.response; Blob body = ...
0
votes
1answer
20 views

cover standardcontroller extension in test class

public DiscoverOrg_ConflictResolver(ApexPages.StandardController controller) { LoadPage(); // Research request start reportSubmited = ''; reportNotSubmited = ''; ...
1
vote
1answer
29 views

Detail Object not available in Test Class

I have an Object- Foo( Master ) and an Object- Hoo(Detail). Hoo is a child of Foo and related by a Master Detail Relationship. I am creating a test class where I need to access Hoo object from Foo. In ...
1
vote
1answer
37 views

Is there a way to test sql queries in exacttarget?

I'm wondering if there is any sort of developer console where you can test sql queries. Testing queries by always looking into the regarding data extension takes quite a lot of time. Anyone having ...
0
votes
0answers
43 views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

I have a test class that was running fine until . Now I continue to get this error message: System.DmlException: Insert failed. First exception on row 0; first error: ...
1
vote
2answers
62 views

Regarding Test Class in Salesforces [duplicate]

How to Write a test Class for Wrapper Class or Dto Class,how to call Wrapper Class in Test Class Please anyone Provide with Sample Example
4
votes
3answers
172 views

Apex Class Variable placement

I was creating a Test Class and my Test class states that the variable is not defined: Global class ContractUpdateContractRenewalStartDate implements Schedulable { global void ...
0
votes
0answers
24 views

Test Class Execution

Below i have a class, i am trying to write a test class, but it only able to cover 15 %. can anyone help me to complete the test class Apex Class: public class CopyQuoteController { Public Quote ...
0
votes
1answer
25 views

Wrapper Test Class Code Coverage

I have a wrapper class i tried test code coverage till 76% ,i am trying to make it 100%: Wrapper Class: public class wrapperClassController { public List<Product_Details__c > pd1 ...
0
votes
2answers
28 views

Can anyone help with Code Coverage on this Trigger

I can't seem to get any code coverage on this trigger. Any assistance would be greatly appreciated. I am suppose to be going live with this trigger in a few hours. trigger populateCaseContact on ...
-5
votes
0answers
35 views

Regarding Apex Class in Salesforce [closed]

I have Written in Apex class in Rest Services using Get Method @HttpGet global static String doGet(){ RestRequest req = RestContext.request; RestResponse res = ...
-1
votes
1answer
36 views

testing a radio button selection functionality

I am testing an updatecase method in my class which look like this: public PageReference createCase() { Case c = new Case(Status = 'New', Origin = 'Phone', Subject = 'This is a New Case ...
0
votes
1answer
20 views

Test pagereference redirection to detail page

I am writing a test for a method in CreateNewCase class. This method in CreateNewCase class creates a new case and redirects the page to the new case's detail page.: public PageReference ...
0
votes
0answers
14 views

How can i write test class for this REST web service class [closed]

@RestResource(urlMapping='/Ordercreation/*') global without sharing class OrderCreationShopify{ @HttpPost global static void doPost() { // Local Variables list < ...
-1
votes
1answer
45 views

test class in Salesforce

why try catch is not executing in testclass? this is sample apex code @HttpGet global static String doGet(){ RestRequest req = RestContext.request; RestResponse res = RestContext.response; ...
-1
votes
1answer
21 views

Test class for a pagereference method

I am trying to test a logic in my extension. I have three boolean variable(I am setting them as false in constructor). In my method displayButton() , if all three boolean value are true then I set a ...
-1
votes
1answer
30 views

Why am I getting the System.DmlException error when running my test class

I am running the test class below and it keeps on giving me the error.Would appreciate your help on this: Here the error message Error Message System.DmlException: Update failed. First exception ...
1
vote
2answers
32 views

Mixed DML operation error [duplicate]

I am facing Mixed DML error in the following case: static testmethod void method1() { User u1 = DataFactory.createUser('testUser','test@user.com','permissionSetAPIname'); Obj1 rec1 = ...
2
votes
1answer
16 views

Query on RevenueForecast object does not return any results in test class

How to get results from RevenueForecast object in a test class? I created Opportunity, PricebookEntry, OpportunityLineItem and OpportunityLineItemSchedule objects. I expect to get a record from ...
2
votes
1answer
15 views

Help with Test Classes for Apex Classes

I am having trouble with getting one of the Classes to get Code Coverage. Below is the Code: public class Match { @TestVisible public List<Common> Common {get; set;} ...
0
votes
1answer
21 views

Regarding apex class to Test Class

I have A Given Sample Apex Code @HttpGet global static String doGet(){ RestRequest req = RestContext.request; RestResponse res = RestContext.response; try{ ...
-1
votes
1answer
18 views

Testing the Extension for a Visualforce page

I am just curious about the following code, not able to achieve 100 % code coverage. Following is the extension and its test class. public class RW_EnquiryFormExtension { public String projects { ...
1
vote
1answer
25 views

How to create a case object with case comment field in unit test?

I try to insert one record in Case object along with case comments, inorder to cover my apex class. However i got an error "Compile Error: Invalid type: CaseComments".Could you please help me how to ...
0
votes
0answers
15 views

How to create a case object with case comment field in test method? [closed]

I need to create a case Object with case comments assigned to it in my test class. Please help me
0
votes
1answer
21 views

Unit testing: Assigning a Custom Obj Auto-Number to String Variable?

I have been trying to successfully compile a Test Class for triggers that auto-insert a DML_Log__c upon a specific sObject type being deleted, and an error keeps getting thrown: Expression cannot ...
-1
votes
1answer
26 views

Test Class is not getting covered Messaging.SingleEmailMessage in batch class

Test Class is not getting covered for singleemailmessage. Part of Code : global void execute(Database.BatchableContext bc, List < Contract > recs) { List < ...
-1
votes
1answer
28 views

Regarding test Class in salesforce 9

In PostMan Using Post Method the Requested Body is in Json Format,same code i am writing in Test Class with RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); ...
0
votes
0answers
18 views

Test class for methods that query Data.com tables such as DatacloudContact

I was wondering if it is even possible to write a test class for a method that makes a call to a Data.com table such as DatacloudContact. When I run the following test class (below) it does not run ...
7
votes
1answer
23 views

Why does an autonumber sequence get “stuck” when creating records after a @testSetup method?

I ran into this while writing unit tests for my org but I simplified it in a developer account to make sure it would happen there. I have custom object Thing__c. The Name field is autonumber. I wrote ...
0
votes
1answer
33 views

Help in test Batch class

I have a Batch class and written a test class where the code coverage is displaying as 50% only.How to cover the single message email in the test class . Batch Class : global class ...
-1
votes
1answer
31 views

call HTTpRequest in test class

public with sharing class HND_Callout { static Contify__c constant = Contify__c.getInstance('constant'); public static HTTpRequest genricHTTpRequest( String EndPointUrl,String ...
1
vote
1answer
16 views

HttpCalloutMock Test class Failing

I have a Class using MetadataService and different methods of it. I want to create a test class for the same but it is giving an error that my test class have HTTP callouts. I am using the ...
0
votes
0answers
27 views

Need help with my test class

I have updated my triggers with few lines of code and a custom setting which will allow me to dynamically activate/inactivate the trigger in production. But now the issue is that my test class is ...
0
votes
0answers
19 views

System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out while releasing package

I never had this Exception before 23th April 2016 when i released package. I've a stub(WSDL class in salesforce) and i'm calling methods from that stub i've written test class with mockClass and ...
2
votes
1answer
23 views

Regarding Apex Class q1

How do you declare a static method inside with another static method? Is it possible? Why are test class methods always static? Can anyone guide me?
2
votes
2answers
30 views

Regarding Apex class

While Executing Apex Class only Top Level Class should Be Declared as Static in Test Class,Why this Error is Occuring ,How to Avoid this Error? @isTest public class BusinessProfile1 { public void ...
1
vote
2answers
37 views

Relationships data not return when on UnitTest

I have been looking all over for a solution. What i have seen in other similar issues online is the error was related to code errors/user errors. I have looked over my code several times and cant see ...
3
votes
1answer
30 views

Apex Test Data - Portal Users

I cannot figure out how to create/insert a Customer Portal user record in an Apex Test. After the necessary google hunt, I came across this piece of Salesforce documentation: Apex Testing with runAs. ...
0
votes
1answer
17 views

How do I attach an Article to a Case in a Test Class?

I am trying to figure out how to fix the part of my test class that is attaching an Article to a Case. section of code from my test class: CaseArticle ca = new CaseArticle(); ca.CaseId = c.Id; ...