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)

-4
votes
0answers
14 views

send the Test class for below [on hold]

public class TemplateAssignment { public static void afterInsertprg(List < Account > account) { List < CEmailTemplate__c > CEmailTemplate = new List < CEmailTemplate__c > ...
1
vote
0answers
12 views

Mock class not working with Dynamic & Unique end-point

i am fetching some remote data into my salesforce and i am using "oauth_signature" in my end-Point URL for remote web services so my API URL is unique for every API request. my all functionality is ...
-4
votes
0answers
22 views

Unable to create Set Test class of custom setting? [duplicate]

My Apex Class.. public class MaxmindSettings { public String APIKey{get;set;} public String firstRating{get;set;} public String secondRating{get;set;} public String ...
0
votes
1answer
26 views

how to create Test class of custom setting?

i am new to apex... My Apex Class.. public class MaxmindSettings { public String APIKey{get;set;} public String firstRating{get;set;} public String secondRating{get;set;} public ...
1
vote
0answers
10 views

Is it possible to get all groups for a user - from the API?

Is it possible to get all groups for a user - from the API? In the Force.com Deleloper Console, with the query SELECT Id, GroupId, UserOrGroupId FROM GroupMember, I get only one result row I would ...
0
votes
2answers
31 views

System.QueryException: List has no rows for assignment to SObject..unable to resolve it

i am new to apex... My Apex Class.. public class StudentLists { public List<Student__c> stuList{get;set;} public String name1 {get;set;} public String eid {get;set;} Public ...
0
votes
1answer
33 views

test class asserts for pagereference

I am new in SalesForce, Please Help me, my Apex Class... public class sturecords { public String name { get; set; } public String address { get; set; } public String phone { get; set; } ...
2
votes
2answers
57 views

Need of Test Class

I have written a simple trigger which does some validation. I am trying to understand, if it's really necessary to write Test Class for this. The code coverage is 0%, hence please someone help to ...
-5
votes
0answers
26 views

salesforce Test Class for Handler [on hold]

some one here give me test class for this Handler blow is my handler code
0
votes
1answer
24 views

Test class on lead conversion trigger is not working

I have created a trigger on lead conversion to create contact of custom contact filed in lead. I have created some custom fields on lead object to capture alternate contact details apart from main ...
0
votes
2answers
53 views

System.EmailException: SendEmail failed in test class

I have a scheduler class for which i have written test class,when running the test class i am getting System.EmailException: SendEmail failed. First exception on row 0; first error: ...
1
vote
1answer
19 views

Testing InvocableMethod

so basically I ripped off http://www.iterativelogic.com/using-invocable-methods-with-skuid/ in order to integrate an automatic Lead Convert Method that can be called from Skuid and I'm unable to test ...
1
vote
2answers
69 views

How to cover the URL redirections in test class?

I have an apex class.In the class i have method with url redirctions.Am unable to cover the method.Please guide me !! Apex method public PageReference urlRedirect() { ...
1
vote
3answers
49 views

How to get a list of Test Classes in an org

I need to get all test classes (classes with isTest Annotation) in an Org.. Is there anyway to filter test classes out of all the Apex Classes
-1
votes
0answers
45 views

How to simulate triggers in unit tests? [closed]

I have a utility class that provides some generic trigger logic. This class is part of a package that can be utilized by subscribers in their local triggers. How can I write unit tests for this class ...
2
votes
1answer
7 views

Test Execution Result History

Is there a history of test execution available for querying after a test is run? In the Salesforce Classic Apex Test page you can obviously see some recent tests, and their results individually. ...
6
votes
1answer
139 views

Apex Test Class - Can You CRUD Without Firing Triggers - On Purpose?

Is there anything built into Apex that lets one perform a CRUD operation on an SObject and suppress the related firing of any Apex Trigger / Workflow Rule / Process Flow? (Similarly to the way one ...
2
votes
1answer
23 views

Visualforce Controller test assertion fails

I have a visualforce controller that populates a VF Gauge on a dashboard. I am working on the test as I got the gauge to look and work how I want. The problem is that when my test class runs the ...
1
vote
3answers
35 views

Test Class for Catch Exception getMessage

I have a class that includes the following: try { stuff.... }catch(Exception e){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()+'ERROR')); ...
0
votes
0answers
16 views

How to test batch with callout with triggers

I have been trying to write a test class for a batchable apex we have for a few days now, and I think I have identified that a managed package has a trigger that is causing a DML event on insert of a ...
0
votes
1answer
30 views

Do Trigger DMLs count on Batch Callouts? [duplicate]

Our instance has some triggers that fire before insert and before update on accounts, contacts, and leads. In a test class, if I am creating test records will the insertion of new account records ...
3
votes
0answers
26 views

How to write test classes for Continuation Controller (using Async WSDL class)

I have implemented Continuation concept with the Asynchronous WSDL class, in a controller of page. So, I facing difficulties while writing test classes for the same. For my requirement I have ...
3
votes
2answers
66 views

Is there an effective way to export Test Coverage result

Although this idea has been talked in Salesforce success community for a long time, currently there is still no Salesforce supported way to export Test coverage report. So is there any third party ...
15
votes
3answers
165 views
+100

Why Are Data Silos Important in Unit Tests?

I have a lot of strong opinions about this issue, but had a hard time finding official documents today to back up my position. A lot of times we say it is bad practice to use seeAllData=true, but we ...
0
votes
1answer
15 views

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY on Apex Test Class

I've been trying to create and implement an Apex Trigger/Apex Test Class for the Asset object to automatically populate an Asset custom lookup field, "Partner_Client__c", with the same information as ...
1
vote
1answer
13 views

Setting profile information for test user in apex test class

I'm creating a test method where I have to create a test user. I will be using runAs for this. But, in creating the actual test user, I'm unsure how to set profile items such as ...
1
vote
1answer
17 views

Test class not picking up contact at account related to opp

I have an opportunity class ext that has: List<Contact> relatedContacts = [SELECT Id, account.id, firstName, lastName, email, Title, account.name, ...
0
votes
1answer
27 views

how to pull opportunity owner name in test class

I wrote a batch class to send email to opportunity owner when the opportunity's close date is passed. global class SendEmailToopsowner implements Database.Batchable<sObject> { global ...
1
vote
1answer
29 views

Apex List Test Failing in Prod But Passes In Sandbox and if Directly Queried

I have a simple getter inside my class that returns a list of cases depending on who the currently logged in user is (in my circumstance this is a Community User). When i run the code in my full ...
2
votes
1answer
16 views

Trouble with PageReference testing

I have a very simple extension to a custom object that I use for three reasons: 1, so make sure that the user's custom profile is being utilized, 2, the classification is set on this specific VF page ...
1
vote
3answers
51 views

How can I increase the code coverage when many classes have already reached the 75% of code coverage mark? [closed]

How should I cover the code when most of the classes have covered the code greater than 75%?
0
votes
1answer
27 views

Need help with a trigger test

I am extremely new to salesforce and am having trouble working on a project for work. I need to test my trigger for adding a discounted quote to an opportunity based off of the original quote amount. ...
3
votes
0answers
40 views

Attempting unit test, “You popped a context which you never pushed…”

Lately when trying to execute a unit test using the Force cli tool I'm getting an error I've never seen before. ERROR: You popped a context which you never pushed, check for unbalanced push and ...
1
vote
1answer
63 views

I cant get my test class to cover the code?

I am trying to cover my class Api_Http_DealerProfileEmail_1 using a test class which covers some other classes too,for some reason it keeps on giving me 0% code coverage for the class. Here is the ...
4
votes
2answers
90 views

Set CreatedById Field in Apex Test Class

I have created a trigger on the Account object that is validated only if the records are being created by an non-admin account. In order to test this functionality I would have to set the ...
1
vote
1answer
25 views

Getting null point in Unit test

In my update I have created a product and I am referring this product to a OpportunityLineItem am getting an error System.NullPointerException: Attempt to de-reference a null object But when I ...
2
votes
2answers
31 views

test class fails system.assert but manual upload performs as expected

I don't understand why when i upload the two invoices in my test class through the data wizard they perform as expected based on the triggers I've written. but when i run this test class it fails due ...
0
votes
0answers
29 views

how to write test class for global class

Here is my code global class Rforce_W2CSchema_CLS{ global class Casedetails{ webservice String ...
0
votes
0answers
10 views

Access to entity 'KnowledgeArticleVersion' denied: Entity is not api accessible Stack Trace: null

When running a unit test accessing KnowledgeArticleVersion in my sandbox everything works fine, but when I run the unit test in PROD, I get the following error: Access to entity ...
3
votes
1answer
24 views

Test.StartTest() and Test.StopTest() works with Time Dependent Work Flow?

I'm not able to find documents on this topic. If my update trigger updates an object which in turn fires a time-dependent workflow that updates a field named "workflowField__c"(update field , 1 hour ...
0
votes
0answers
37 views

Inserting person accounts in test mode

Inserting person accounts in test mode Hello My envrionment is using personAccounts. While I was developing my code I was running a testing method so my code will insert a person account. To my ...
0
votes
2answers
27 views

Testing a method with sub methods

I have a class where I call a function , which in turn calls various functions, ex: Class foo{ void parentmethod(){ method1(); method2(); method3(); } List<SelectOption> method1(){ // do ...
0
votes
2answers
38 views

Test class code Coverage

Can any one please help me with the below trigger to get the code coverage. Trigger: Trigger TaskEmailNotification on Task (before update ) { Set<Id> ownerIds = new Set<Id>(); ...
1
vote
1answer
37 views

Invalid Role Assignment in Test Class

I have a test class that works in my Development Sandbox but doesn't work when Validating the Change Set in Production. We have a Partner Community, and the test class creates a user with a Partner ...
9
votes
1answer
222 views

Is it possible to have Test.startTest() and Test.stopTest() in a loop?

First of all, sorry that I couldn't frame the question better. But I will try my best to explain why I am asking what I am asking: There are multiple custom objects like Client_1__c, Client_2__c, ...
0
votes
1answer
30 views

Scheduled Apex Class Testing Issue

I am trying to test a scheduled class in apex, but upon running the test method it gives me the following error: System.JSONException: Unexpected character ('0' (code 48)): was expecting ...
-1
votes
1answer
39 views

How to write test case for this method where try and catch code is cover? [closed]

@RemoteAction public Static List < Document__c > GetMarketingDocuments(string opportunityId) { try { string queryString = ''; List < DroisysOne__Document__c > docs = ...
3
votes
1answer
41 views

How to test for Visualforce required fields in Apex?

I have a VF page with some required fields on it. These fields are not marked as required in the data model, and my controller is not doing any validation on them either. How can I properly test this ...
2
votes
1answer
34 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
28 views

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

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