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)

0
votes
1answer
12 views

How to create Hierarchy custom settings in Apex

I need to create Hierarchy custom settings in my test class to avoid the seeAllDate = TRUE Little confused on how to create Hierarchy custom settings. Looked at the docs and other questions but don't ...
-1
votes
2answers
26 views

Simple trigger unit test, still getting 0% code coverage

The trigger: What I have been trying for the test class: I am a total noob when it comes to writing these unit tests. I would greatly appreciate any guidance to help me get this figured out.
5
votes
1answer
29 views

Summer 15' Unit Testing @testSetup DUPLICATE_VALUE Issues

After wasting an entire day attempting to deploy a huge release to production I'm graveling at the feet of the Salesforce community. So many issues when attempting to package my release (including ...
0
votes
1answer
25 views

Test Class AssertEquals not finding correct value

I am encountering something odd with this test class, and I either do not know how to phrase my issue, or it is just odd. I have 2 triggers that I am checking. The first trigger is on an Opportunity. ...
0
votes
0answers
20 views

Trigger need to set for the below issue [on hold]

I had created CREATE JIRA button into CASE & want to set some condition. Type (Picklist) - Containing Values --> A, B, C, D If Type (Picklist) = B and saves the record and if user will click on ...
0
votes
0answers
29 views

What does it mean to move the @TestVisible member variables into a separate section? [on hold]

I have some private variables in a class where I have put @TestVisible so that I can use them in the test class. In a client code review, the client said they want this in separate section. Here is ...
1
vote
2answers
33 views

Getting null value from standard getter method of sObject

I am stuck in a very strange situation. I have one custom object (test_Boolean__c) and a field of checkbox type (check_Boolean__c) whose default value is true. Now this is what I did :- Created a ...
0
votes
1answer
18 views

Assistance with test class for VF controller extension

I have a controller extension for a visual force page that currently has 0% coverage. A test was never written for it and I'm quite a novice when it comes to programming but I've got to start ...
2
votes
1answer
13 views

Salesforce: APEX Test Class for Web Service

I've created a basic frontend that dips into my force.com data by way of a Public Guest User and a webservice call. Essentially, the code is requesting the Rate (aka cost) of various items that a user ...
-3
votes
1answer
16 views

From Salesforce JIRA issue will Automatically Create

I want to set the some condition in Salesforce CASE. Whenever user click on the "CREATE JIRA" button in case, the JIRA issue will automatically create into the JIRA tool. It is possible to do this ? ...
0
votes
2answers
17 views

Test Class for Campaign Member Trigger

I am writing a test class for a trigger and am having some difficulty developing a test method. My trigger is on the CampaignMember object. When a new member is inserted AND that CampaignMember is a ...
-3
votes
1answer
30 views

How to write Test Class for following Trigger?

trigger HandleProductPriceChange on Merchandies__c (after update) { List<Line_Item__c> openLineItems =[SELECT j.Unit_Price__c, j.Merchandise__r.Price__c FROM Line_Item__c j WHERE ...
0
votes
1answer
15 views

enable and disable a checkbox field after test?

I need help writing a formula for the following scenario: I have 2 Checkbox fields on a custom Object: Approved_by_Manager__c and Bc_sent__c. The test: if Approved_by_Manager__c is checked then ...
2
votes
1answer
20 views

What is the difference between Test.setCurrentPage vs Test.setCurrentPageReference?

I noticed that there are two methods in the Test class, looks like for the same purpose: public static Void setCurrentPage(PageReference page) public static Void setCurrentPageReference(PageReference ...
1
vote
3answers
107 views

List not empty after deletion

I have a Test Class which retrieves a list of junction object records, created earlier in the Class & deletes them. List<SellerxProperty__c> sxpJosToDel = [SELECT Id, Property__c FROM ...
0
votes
1answer
22 views

Code Coverage Increase

What I am missing I can not do the code coverage for the for loop. public class myControllerClass{ public string aText{get;set;} public string iText{get;set;} public myControllerClass () ...
0
votes
3answers
33 views

Code Coverage not working on tests

So, I did a button linked to an apex class which turns a candidate into an account when a recruiter wants, when I try to deploy it on production it says that I have 72% of test coverage, but when I ...
2
votes
1answer
31 views

Find out which test classes hit a particular class

Does Salesforce have a functionality that lets you identify which test classes (and possibly which of those tests) cover a particular Apex class? I know that if you run a test class then you see ...
1
vote
2answers
26 views

Unit test deadlock

background story: We slipped under the 75% test coverage. In addition to writing new tests I deleted some old classes (no longer needed ones). Problem: Deleting classes which are still referenced in ...
0
votes
1answer
27 views

How to query another Objects field to get it's value

How do I query the value of Contact.Country__c? It is to be connected with Case. For now my code is: @isTest public class WebToCaseCountryTest { public static testMethod void testTrigger() ...
3
votes
2answers
28 views

Assertion keeps failing in test class

I keep getting an assertion failure with my test class for the following trigger: trigger WebToCaseCountry on Case (after insert) { Set<String> countries = new Set<String>(); ...
1
vote
0answers
24 views

Reminder email need to send to the users

I need to send the Reminder e-mail to the below user & all the below users belongs to the same PROFILE (Test1) : 2 pm UK time on Thursday of every week. User1 – UK – time zone BST (GMT + 1) ...
0
votes
1answer
14 views

Trouble with writing a test class for this Trigger

I am trying to write a test class for the following trigger: trigger WebToCaseCountry on Case (after insert) { Set<String> countries = new Set<String>(); for (Case c : ...
1
vote
2answers
120 views

Having problems with a trigger and its test class

I have been working on this trigger for the past day and a half and I cannot seem to get it to work how I need it to. I have done triggers before and can usually figure out what needs to be done with ...
0
votes
1answer
26 views

Why is this insert statement causing an error?

Could anybody enlighten me as to why this piece of code is causing an error when I try to run it in Execute Anonymous? This is the code I am running from my test class: List<Case> newCases = ...
0
votes
1answer
32 views

System.runAs(new user(ID = UserInfo.getUnserID());

What does this mean? System.runAs(new user(ID = UserInfo.getUserID());
0
votes
2answers
40 views

How to rectify “uncommitted work pending”?

I have created class and test class. I got an error like this System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out ...
0
votes
0answers
8 views

Test class for http callouts and code coverage [duplicate]

How to rectify this error like this: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out in test class for http callouts?please find the screenshot ...
1
vote
1answer
15 views

Test Class Help - Are the correct fields being tested? [closed]

I feel like I should create a new Contact in the test class so that I can relate it back to the Case. Would this be the right way to go about it? Basically, to test I want to: Create a case and ...
2
votes
1answer
28 views

Capture data during test execution

We have huge number of test classes and we are trying to automate capturing information about existing test classes. Data we are trying to capture is around governer limits (e.g. number of soql ...
0
votes
1answer
23 views

Custom Labels and tests

Can I access the value of a custom label during an Apex test? Do I have to use "SeeAllData=true" to get the value? If so, what value do I get back when not using "SeeAllData=true"? The documentation ...
0
votes
2answers
34 views

How do i cover this test class declaration?

I have written a test class for my apex class and was able to cover all the lines except these three lines HO do i cover this? Apex class: Test Class: @isTest private class Test_GNWAVMService { ...
-1
votes
2answers
34 views

does a test class need to pass?

I have written a test class for my apex class The test class covers 98%. but the test class fails. will the coverage be considered.?
1
vote
1answer
49 views

how to create mock test for rest api?

This is my rest api class,in this class need to write mock test class global class Searchaddress { @RemoteAction global static list<String> restapi(string accName){ string ...
0
votes
1answer
33 views

Selected job is not yet complete in Test Class

I have written one Test class in which Test class is working Fine, But Code Coverage is 0% and after running the Test Class i am getting "Selected job is not yet complete in Test Class" . Trigger ...
1
vote
2answers
45 views

How can i improve test coverage?

I am new for test class but I have covered 54%.My class having web service i don't know how to write test class to web service. Please can any one help me out.I need to move production.. Apex class: ...
1
vote
1answer
18 views

Can any one give me some idea how to write a test class for the below mentioned batch class

global class batchorgUpdate implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'SELECT Id,Name, ...
0
votes
2answers
74 views

Can any one give me some idea how to write a test class for the below mentioned code [closed]

Can any one give me some idea how to write a test class for the below mentioned code struggling for this. public with sharing class Select_Distributor_Controller { public string ...
1
vote
1answer
19 views

Test class on a class contained by another class

I have to write a test class for an apex class which look like that : public without sharing class HController{ //public user currentuser{get;set;} public Account personContact; ...
1
vote
1answer
25 views

Why Test Data Factory class begins with @isTest?

I am not able to find an answer to why the Test Data Factory class begins with @isTest. Does anyone here have a clue ? Thanks
0
votes
1answer
32 views

Test class for trigger that changes recordtype on a sObject dependant on status condition

This is my trigger: trigger contractStatus on Contract (after insert, after update) { Set<Id> accIds = new Set<Id>(); List<Account> newAcc = new List<Account>(); ...
1
vote
1answer
20 views

Methods defined as TestMethod do not support Web service callouts, test skipped : how to overcome this?

I had tried to cove a apex class with my test class. I am able to get 98% code coverage,except thet the test class is failing due to this error: Methods defined as TestMethod do not support Web ...
0
votes
0answers
22 views

Need help for writing test class?

I am new for test class but I very eager to learn for that, I have created class. Please can any one help me out to my class. global class Searchaddress { public String ...
1
vote
1answer
35 views

{get;set;} test class

How do i get coverage for this type of {get;set;}? Apex class: public Boolean viewMode {get;set;} public Boolean editMode {get;set;} public Boolean hasError { get { ...
0
votes
1answer
20 views

test class for Rfleet_PaymentConditions

I have create a apex class(Rfleet_PaymentConditions) and when i am writing a test class,i got only 29%.how to achieve 75% code coverage? apex class: public class Rfleet_PaymentConditions { public ...
1
vote
1answer
35 views

(!Test.isRunningTest())-How do we write test class to cover this?

I have written a test class for my apex class. I am able to cover all portion except this how do i cover this
0
votes
1answer
20 views

Error Attempt to de-reference a null object for test class

For the method below, I have written test class. But getting error at fetchInit f = new fetchInit(); inside the method. Error: Attempt to de-reference a null object. How can I avoid this error. Also ...
-1
votes
1answer
28 views

Test Class - System.ListException: List index out of bounds: 0

public class APShippingChargesApplytoDealController{ public AcctSeed__Account_Payable__c Ap {get;set;} public List<Deal__c> dlList {get;set;} public String apId {get;set;} public ...
0
votes
1answer
19 views

Trying to use some of my Managed Package apex code in a test class in an Extension Package

I have an Apex class in my Managed package that contains the standard methods that do most of the work in our application. Here is a little snipped of the managed package code... public with sharing ...
0
votes
0answers
38 views

test class for trigger apex

For the below trigger i am unable to pass the condition to get 100 percent code coverage. trigger: trigger populatePrimaryContact on Contact (after insert, after update) { boolean ...