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)

1
vote
2answers
23 views

Lead conversion unit tests throw errors for validation rules that use custom settings

I'm running into an odd issue with some of my unit tests & can't seem to find out what exactly is causing it the problem. Several of my unit tests revolve around converting a lead to an account ...
0
votes
1answer
20 views

I have created a trigger, which generate's a random string, Please can any one help in writing the test class?

trigger setGuid on dftly_app_contact__c (before insert) { For (dftly_app_contact__c dac: Trigger.new){ Blob b = Crypto.GenerateAESKey(128); String h = EncodingUtil.ConvertTohex(b); ...
4
votes
1answer
22 views

Test.StopTest Not Resetting Limits?

I have a test running in API Version 29. I am actively testing against governor limits and I think I am running into a bug. My test has the following sequence: //setup Test.startTest(); // ...
-1
votes
1answer
24 views

How do I write a test class/test method for a controller?

As I'm new to SFDC, I've recently written a basic controllers for visualforce pages, and now need to test them. Problem is I don't know how to test the thing. can someone help me get started?. ...
0
votes
0answers
28 views

Report code coverage from a deployment

Is there a way to get a report of the code coverage during or from a deployment? Currently I have 85% total coverage in my production (cleared all test and ran all test to be sure this is accurate), ...
1
vote
1answer
32 views

Developer Console - Testing Issue

We are getting strange behavior with the Developer Console when running our unit tests. We complete development with the force.com IDE and use the dev console for unit testing (for performance & ...
1
vote
2answers
39 views

Low code coverage, when production and new test class to deploy are over 80%?

I am having an issue, for the last couple of days and I dont know how to fix it. I have run all the test classes in production, when I open my developer console, the overall code coverage is 79% (of ...
0
votes
0answers
39 views

Apex Test with several methods not included in code coverage

I have created an APEX test class to test and cover one of my class. This test class has 4 methods. When I comment one of them and run it, the code coverage is the sum of the code coverage of the 3 ...
-1
votes
0answers
14 views

test class for wrapper class with check box involved [closed]

I have wrapper class being used in front end to provide the check box functionality, i need to write the class as my code coverage is falling under the min coverage. I have googled many sites, yet the ...
0
votes
0answers
12 views

Wrapper classes are not getting covered though object gets created and functionality runs.

I have few classes which I have created for Json request format. When I run the func in test classes, everything covers but wrapper classes. for example let's say I have to send {"stack ...
1
vote
1answer
24 views

How to remove or modify a test class?

The standard test class Milestone1_Email_Handler_Tst is causing problems when I attempt to deploy new code to our production system. System.AssertException: Assertion Failed Stack Trace: ...
6
votes
1answer
69 views

Why would my test class throw a Duplicate exception?

I have a test class. The annotation on the class is @isTest(SeeAllData=false) In the test, the first step I do is create a user. I am getting the following exception when I run my test. ...
1
vote
2answers
32 views

Test Class for BATCH APEX[Constructor not defined: [ModifiedDate_Test].<Constructor>(String)]

I am having trouble creating a test class for this particular class. If anyone could provide some code that would implement this I would be very grateful. Many thanks CLASS global class ModifiedDate ...
0
votes
1answer
49 views

CombinedAttachments Table subquery is not returning any result in Test class

In below test class method, the subquery is not returning any result even after inserting the attachment. Test CLass : @isTest private class AttachmentRelatedListController_Test { ...
2
votes
2answers
26 views

How to write apexmessages in testclass at that step it shows error?

Controller: public class AccountOppRecords { public list<opportunity> opplist{set;get;} public string accname{set;get;} public string oppstname{set;get;} public AccountOppRecords(){ } public ...
0
votes
2answers
67 views

Could not get code coverage to 75% for an incredibly simple apex class

Posting the code here as SampleReports and its associated test class. Always says that line 16,17,18 and 19 are not covered inspite of the test method that I have written. public class SampleReports{ ...
0
votes
0answers
26 views

Code Coverage in Production is reflecting as 0% (No coverage data)

Can any one help on this.I have two triggers with their test classes.Using changesets i have moved into production.In Sandbox for trigger1 i.e caseDuplication Test the code coverage was 90% and for ...
0
votes
0answers
24 views

Test class for Apex Trigger fails

Can any one help me out on this?how to write a Test class for the trigger.Any help is very much appreciated. Trigger trigger ReparentComment on CaseComment (before insert) { Map<String, ...
0
votes
1answer
14 views

Test Class Code coverage for a trigger is 70% and Error as :Only top-level class methods can be declared static

Can any one help on this .I have a trigger written on Case object for the duplication to get it closed .I have written a Test class where it gives the code coverage as 70% only. When i Execute in ...
0
votes
1answer
22 views

How to Identify the Test Code Written for trigger

Can any one help me.I have written a Trigger and test classes .When i check in the sandbox i could see only the trigger and the test classes got disapperared .I checked in the Apex classes and in ...
0
votes
2answers
18 views

regd Test class

I'm writing a test class on Opportunity which is testing trigger which execute on update. I've simple questions- I'm trying to print user which has created opportunity in this test class. I'm using ...
0
votes
0answers
38 views

Testing controller extensions with a feildset for by custom object

From past few days i'm working on writing an Apex test for my controller extension. I've created a dummy record for my custom object then passing the id in the constructor while invoking my extension. ...
0
votes
0answers
9 views

How test Angular Salesforce page, body content using phantomjs

I'm trying to test a Salesforce page using Phantomjs, I'm able to get everything BUT anything inside my html-data-ui-view="" attribute. Is there anyway to get the body content? And yes I've seen ...
0
votes
1answer
32 views

(0/1 test methods passed) Help [duplicate]

I'm trying to make this test method work. //test @isTest private class CoreValuesExtTestClass { static testMethod void validateCoreValues() { Core_Values__c cv = new ...
0
votes
0answers
6 views

Is there already a way to run Salesforce test classes using TestNG?

My client has test management software that integrates with TestNG (Selenium). Rather than run manual tests, I would like to use automation to run my Salesforce test classes and capture defects, using ...
1
vote
0answers
12 views

Issue with Query during Test on User Object after Winter 15

Specific example that I did not see in other questions: Unable to query user object when filtering on ProfileName and Limiting result during test in production Have a test class passing in full ...
0
votes
1answer
22 views

Testing a scheduled class

I have two methods in a scheduled class. Both resemble the code below. I'm getting the following error when I call the second version. System.AsyncException: The Apex job named "My batch Job" is ...
-1
votes
0answers
7 views

Test method that makes sure your execute method of queueable object operates correctly

I have a after update trigger, based on the update of few values of a object, I sent the object to a queuable object. This queuable object in turn makes sure it sets up the queue and using the execute ...
0
votes
1answer
18 views

Static boolean is not initialized when the code is called from a test method

public UtilClass { public static Boolean someBool = true; public static List<SomeObject> someMethod() { . . if(someBool) { // do something } ...
1
vote
1answer
59 views

How Do I Write A Test Class For A Trigger Using The Below SOQL Query?

Dear fellow SalesForce StackExchange, I got the following SOQL query working in Workbench. (Note: If any IDs look invalid, it's because I did some typing-over them to anonymize my code, and I may ...
-1
votes
2answers
58 views

Error on test class

My trigger is : trigger TaskTrigger on Task (after insert) { List<Order> ordersToUpdate = new List<Order>(); for(Task t : Trigger.new) { if(t.WhatId.getSObjectType() == ...
2
votes
2answers
137 views

Why (seealldata=true) results into more code coverage?

I wrote a trigger to prevent more than n incidents for a client(lookup to user) at any point of time. trigger CountLimit on Incident__c (after insert,after update,after undelete) { Set<Id> ...
0
votes
0answers
29 views

Test Class for Opportunity Update

I have a test class where I am trying to cover code on an update trigger when the Effective Date or Stage is changed. However, when I run the test, none of the Opportunity data gets changed. Do I ...
1
vote
3answers
41 views

Record Type Name in Test Class [duplicate]

I have a test class that creates records for use in unit tests. One of the components creates an Opportunity record, but I don't know how to add a Record Type to the Opp. I know I can use ...
0
votes
1answer
25 views

Test Class error while having an OrderItem into it

Hi I am trying to have an orderitem into my test class in order to test a trigger. class is : ` public static testmethod void TaskTrigger_Test1() { Account a = new Account(`enter ...
1
vote
1answer
61 views

Problem with test class - Too many SOQL queries 101

I have a test class that is failing due to too many SOQL queries. I'm assuming the fix is quite easy, but am struggling with how to bulkify the query. Can someone please assist? Full test class is ...
0
votes
1answer
17 views

Test Class Problem

I am having a hard time to run my test class for my trigger WHERE my trigger updates the Contacts Mailing to Accounts Biliing Address whenever the Accounts Billing Address is updated. This is my ...
1
vote
2answers
57 views

test class for a trigger

I have 2 triggers into sandbox that work s perfectly and I want to transfer it into production. The only problem is that I need to write a test class for each one in order to cover 75% of the triggers ...
-2
votes
0answers
16 views

I had Written the Test Class it is Showing Any thing else could u help me?

public class Displayrecords { public list<Account> acclist{set;get;} public Displayrecords(){ acclist=[select name,Rating,AnnualRevenue from account limit 7]; } } @istest(SeeAllData=true) ...
0
votes
2answers
23 views

Unit Testing - Workflow Field Update

A SF newbie here. Is it possible to write a test class that can check WF field updates also ?. I have a WF update created on a Custom object CaseLog__c. Is it possible for me to write a Apex Test ...
3
votes
1answer
122 views

Best Practice - Lightning JS (Code reuse, testing frameworks and IDE support)

I asked about the difference between controller and helper and it prompted me to ask another, more specific set of questions: What is the best way to reuse JavaScript code across Lightning ...
-3
votes
1answer
23 views

Test class error [closed]

i have to pass the test class but the error is not resolving iam not bale to find the error can you please help what i have to do to pass this test class System.DmlException: Insert failed. First ...
2
votes
3answers
42 views

How to catch the field not in SOQL query error in a test class?

Is there any way to get this error: "Object row was retrieved via SOQL without querying the requested field: Any_Field_Name " in a test class so that if a new field has been added to the page, I can ...
0
votes
1answer
71 views

Spring '15 @TestSetup doesn't work

This test is supposed to succeed in a Spring'15 org, but doesn't. @isTest private class MyTest { static Integer value = null; @isTest static void testMethod() { ...
2
votes
1answer
74 views

Querying Time-based Workflow Queue

Is it possible to query the content of the Time-based Workflow Queue from an Apex unit test to assess that a specific Workflow Rule has been executed and added a new item to the queue? I didn't see ...
0
votes
1answer
55 views

Need code coverage in if ,else blocks

Hi can anyone help me how to make code coverage for the following scenario? public PageReference doChanges() { selectedLineItems = getLineItemSelection(); if(selectedLineItems.size() > ...
0
votes
0answers
44 views

Test Class - How to create a Partner Account

My need would be to create a Partner Account (that is: an Account with field isPartner set to true!) in test class, having checkbox PartnerAccount set to true, but I'm not having success with this ...
0
votes
0answers
50 views

Test class for apex class containing external objects soql query

I wrote a test class for external objects. Since external objects are read only. I queried the external object record in test class. Created a new instance for controller in test class. When I ran ...
0
votes
1answer
30 views

About Apex Test classes

Few questions creating some confusion for me: Do we'v to write ALL SOQL and DMLS before test.start or after test.start method ? For e.g in case of DMLs, If I'm creating test Data for an object and ...
0
votes
2answers
43 views

test custom exception in catch block

I am trying to do a negative test and cover the catch block that uses a custom exception. Whatever I try it does not enter into my catch block? Here is my controller: public with sharing class ...