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)

3
votes
2answers
15 views

Failing test is showing as passed

In Debug Logs I can see a System.NullPointerException for the unit test that was just run, but on the Apex Test Execution page I see the test as passing. The error is not buried within the log ...
0
votes
1answer
18 views

First Test Class - static data

I'm completely new to Apex, and self-teaching a lot through examples. I just completed [with this community's help!] a custom VF page with "industry news" twitter feeds. It's a basic page, with each ...
2
votes
1answer
30 views

Help testing a case standard object trigger

I need help testing a trigger written against the Case Standard Object. It keeps failing at 74% and I don't understand why? Here's what I have... any & all advice is appreciated. TRIGGER trigger ...
2
votes
1answer
29 views

Test coverage for FeedItem

I'm trying to get my test coverage up and I'm having a few problems to get it done. I have a trigger that will call a class every time a user inserts or updates an event. If that event contains an ...
3
votes
1answer
36 views

Describe call inconsistent in test class

In the Apex class below (executed in a client org), testA() passes while testB() fails. The failure is an assertion error from the ServiceLayer constructor. /* SF API 33 */ /* PKG version 1.55 */ ...
0
votes
0answers
33 views

I need to test this method in a test class, someone can help? [on hold]

public class ROPedidos_v2 { public static ROUtils.UsuarioRevendaOnline usuario {get; set;} public static String getNomeRevenda(String revendaId) { Account acct = null ; ...
0
votes
0answers
7 views

Cyclomatic Complexity for Salesforce Configuration work

Any idea how to calculate the cyclomatic complexity for Configuration work in Salesforce? Thanks.
0
votes
1answer
17 views

“Required fields are missing: [ProfileId]: [ProfileId]” when running Apex Class Test for ChatterAnswersAuthProviderRegTest

I am conducting an Apex test for ChatterAnswersAuthProviderRegTest, as I run this test, I encounter the following error message. System.DmlException: Insert failed. First exception on row 0; first ...
0
votes
2answers
36 views

Need help raising Code Coverage

I've been working on a trigger to auto-populate some information that goes into our company's Tasks. I have come up with the following trigger/test class but can only seem to get Coverage around 45%. ...
1
vote
1answer
31 views

redirect callout to mock callout

I have a utility class where we use to call when making request. This request can be with different classes that uses the this utility class. Here is the sample: public with sharing class ...
-1
votes
1answer
25 views

Methods defined as TestMethod do not support Web service callouts, test skipped [duplicate]

Getting the error after running the test, and the code coverage for the class is 73%. I would appreciate if you could point me in the right direction. Class and the test class is below for your ...
1
vote
1answer
15 views

Issue with URL Parameters not decoding during Test Methods

Typing the URL into the browser with the following params: rec=atWAzwsBvm3hyWrApj4mBo0BsaasxAmfySPTrXZxNVbdPIMHXr1FfVg2Fhoa%2B7FY NOT During a test method executing the line: ...
2
votes
1answer
75 views

System.debug not appearing in logs from test method

I have the below test method : static testmethod void addToShoppingCart_Test(){ //Line 128 setup(); //Line 129 oppObj.pricebook2id = customPb1.Id; //Line 130 upsert oppObj; //Line 131 ...
-3
votes
2answers
39 views

Getting 0% code coverage for following trigger [closed]

trigger Risk_NegativeQuantity on OpportunityLineItem (before insert) { if(Trigger.isInsert) { set<id> oppid = new set<id>(); for (OpportunityLineItem oli : ...
2
votes
1answer
31 views

pricebook entry is in a different pricebook than the one assigned to the opportunity

Could some body please help me on this? I am improving test coverage and below is my code: static testmethod void opportunityLineItem_Test(){ Id priceBookID = Test.getStandardPricebookId(); ...
1
vote
2answers
35 views

Apex Trigger test Class Issue; No Standard Price Defined

Here is my Apex Trigger trigger ProductNameTrigger on QuoteLineItem (before insert) { list<QuoteLineItem> plist = new list<QuoteLineItem>(); for(quotelineitem q : [select id, ...
1
vote
2answers
12 views

Cleared Code Coverage cache

How can I clear the code coverage and I'm stuck to 60% and regardless its not what test I write its not increasing but my question is: is there a way to flush the cache?
0
votes
1answer
16 views

Method does not exist or incorrect signature

@isTest private class cSearchTest{ @isTest static void testbuildQuery(){ Profile p = [select id from profile where name='Standard User']; User u = new User(alias = 'standt', ...
2
votes
0answers
25 views

Centralize Object Initialization - (Insert Event with Attachment on same code)

I have a piece of code that sets a Boolean (has_Attachment__c) field to true in an After Insert context variable is executed in an Event in which an Attachment is inserted on the same time. The code ...
2
votes
1answer
25 views

Trigger isTest coverage stuck on 61%

I have already spent few hours trying to figure out why I'm stuck on 61% and try to add or remove the test methods but no avail. I have the following test class that is only getting 61% coverage on ...
0
votes
1answer
16 views

Test class code coverage for createdfield [duplicate]

I have an apex trigger that do the update the createddate field on parent when the child record is created. I'm not able to get the code coverage for the createddate field. Thanks in advance Here is ...
1
vote
1answer
18 views

Problem with Test Class: System.QueryException: List has no rows for assignment to SObject

I am having issues getting test coverage for my redirect method within my controller. The error I keep getting is "System.QueryException: List has no rows for assignment to SObject" located where I am ...
6
votes
2answers
173 views

When to use Test.startTest?

I am new to salesforce development and I am quite not sure on when to use the below two methods: Test.startTest() and Test.stopTest() 1) Do i need to surround all my insert, update,SOQL and DML ...
1
vote
1answer
19 views

Can't see user_debug from trigger handler when running unit test

Got a system.debug() inside a trigger handler. When running test class, nothing is output to log. Works when trying the same in UI. What could be the problem? Checked my test class overrides to no ...
0
votes
2answers
37 views

Error: Compile Error: Illegal assignment from String to Boolean

as I writing a test class, I come across this error as I am attempting to save my file. Error: Compile Error: Illegal assignment from String to Boolean at line 15 column 13 Are there any ...
3
votes
1answer
45 views

Site.getPathPrefix() is Null even when page reference is set

I am writing a test class for one of my controllers. And in the test class i am setting the current page as given below pagereference pageref1 = new pagereference('/apex/E2E_Screen_2'); ...
4
votes
1answer
271 views

Why am I tripping over this validation rule?

While setting up a test fixture, my code fails when a FIELD_CUSTOM_VALIDATION_EXCEPTION is thrown during an Account record update. Here is the relevant part: theAccount = [select Id, Status__c, ...
0
votes
1answer
11 views

How to write assert for the test class which includes ParseXML?

static testMethod void testmet() { Rforce_BcsRbxParsing_Class bcpe=new Rforce_BcsRbxParsing_Class(); List<Rforce_BcsRbxResponse_Class> bcsList=new ...
0
votes
1answer
14 views

FLS Code Coverage issue

Need code coverage for my IF block if (!Schema.sObjectType.Account.fields.Name.isCreateable()) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, ...
1
vote
1answer
20 views

What are “tid” and “len” in Visual Force Remoting actions?

I have no knowledge of the SalesForce1 platform, but am required to performance test a few UI pages/endpoints of a customer applications using a JMeter script. SO far I have been able to invoke most ...
0
votes
1answer
43 views

Same test class works in one sandbox but not another

I have one test class which is working fine in one sandbox but same test class is getting failed in other sandbox. Below method is not working in Sandbox which may be cause of error. Error: ...
0
votes
3answers
43 views

Test class for @future class

Hi I have the below trigger and future pls help me on how to write Test class for this:- trigger Contactcallout on Contact (after update) { Map<Id, String> m = new Map<Id, ...
1
vote
3answers
46 views

Test class for trigger with if else

i am new to Salesforce and i am trying to write a test class for code coverage to a trigger. Trigger's functionality is working fine, but everytime i try to run Test class the test coverage is showing ...
2
votes
1answer
57 views

trigger.OldMap != trigger.newMap test class. Cannot cover update condition?

I have a trigger that has two conditions, insert and update. On my update condition, I check to see if the Billing Zip Code has changed, if it has, the trigger fires. My trigger works fine but I ...
2
votes
2answers
48 views

Access For User in a Community in a Test class

Is it possible to assign a user access to a community when creating the same in an apex class? Currently I am trying to create a user from an apex Test class and I am providing the user with a ...
0
votes
2answers
31 views

how to use a list name in system.assert in a test class?

In my Test Class i have a list. I have to use it in System.assert() method For Eg: If the list is not null , then the message is "Success". How to do this ? Please provide a solution
-1
votes
2answers
54 views

Creating test code for an after insert trigger [closed]

I've got some code I've inherited with no test coverage and fairly little knowledge of apex. trigger UserPartnerSharing on User (after insert) { List<OpportunityTeamMember> NewOppteam = new ...
1
vote
1answer
36 views

Test Class is referencing wrong Apex Class [closed]

So I wrote a Test Class (for Controller) but on running it is throwing an error for a different Apex class(on Quote) that I've not written, my Apex Class: public with sharing class ctrlname{ ...
0
votes
1answer
90 views

Problems writing a Test class for the salesforce OpportunityTerritory2AssignmentFilter class

I am trying to write a test class for OpportunityTerritory2AssignmentFilter It implements the TerritoryMgmt.OpportunityTerritory2AssignmentFilter and is a sample class provided by salesforce. Has any ...
3
votes
2answers
88 views

Testing batch class

I've a batch class in which I pass query as well as few parameters in its constuctor, like: bclass1 b1 = new bclass1(query1, 'x') ; bclass1 b2 = new bclass1(query2, 'y ') ; bclass1 b3 = new ...
2
votes
2answers
33 views

How to limit control flow during unit test?

I want to limit the control flow during a unit test so that it does not leave the method being tested. The unit test is for a controller method, and in that method the controller creates an object and ...
2
votes
3answers
62 views

How to test apex code that is driven by formula fields (Best Practice)?

Question Are there any best practices out there for testing apex code that is driven by formula fields so that changes to the formula field formula don't break your test? Background Good test ...
2
votes
1answer
36 views

How can I get the product ID in a test case from a OpportunityLineItem?

I have followed the instructions here How to Create Opportunity Line Items in Test Classes When I try to run the test the Product2ID on the Line Item is null. How can I fix this to get the correct ...
1
vote
2answers
51 views

I need 1:1 help with some Apex code coverage issues, how to ask? [closed]

I want to respect the community here so I'd love your feedback on the best way to go about this: I inherited an org with some code coverage issues. I'm a beginner developer at best and trying to work ...
0
votes
3answers
40 views

Test Class doesn't push values into a trigger; Getting: System.NullPointerException: Attempt to de-reference a null object

I have trigger that on deployment is throwing a NullPointerException. The error is: Trigger.tgr_send_enrollment: line 13, column 1: [] System.DmlException: Insert failed. First exception ...
0
votes
0answers
27 views

Test class assumption failing after 2 years

I have a test class that has been in production for nearly 2 years. It is mostly self contained including an XML string that is interpreted and then broken into the component parts and stored. Then we ...
0
votes
0answers
29 views

Unit tests dependent on Process Builder record creation failing

I have 2 process builder (PB) flows: The first creates 3 record in a custom object when a new quote is created. The second creates a new custom object (same object as first PB flow) record when a ...
2
votes
2answers
65 views
+50

Test ControllerExt for Flow

I am trying to get coverage up for the following controller extension which I am using with Flow public class ClosedLoopMarketingFlowExtension { private final Contact cont; private ...
0
votes
0answers
26 views

account name - field value required issue

I'm encountering an odd problem with the account name field. When entering an account name either thru the UI or in unit tests I get the error required field missing [name], but I am filling in the ...
-1
votes
1answer
34 views

I have written test class for this trigger where code is not covered at acc.adderror line? [closed]

Test Class: @istest public class Practice_All_in_One_TestClass{ static testmethod void Practice_All_in_One_TestClass() { account acc=new account(Description='ggg'); insert acc; account acc1=new ...