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

1
vote
1answer
15 views

Does @isTest(OnInstall=False) have any effect on unpackaged code?

I am wondering if using this attribute will keep my test from running when I push code from sandbox to production? Specifically I would like to use this to create bulk tests that I may not want to ...
1
vote
1answer
24 views

Testing Code Dependent on FieldSets

I have a class that uses a field set to build out a dynamic query. This fieldset is passed into the class. Is there anyway I can create a test fieldset in my apex code so I don't have to hardcode ...
1
vote
2answers
36 views

deploy run test pass, but still display Test coverage of selected Apex Trigger is 0%, at least 1%

deploy issue: run test pass, but when i deploy to production, it still display Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required, can anyone tell me what i miss here ...
3
votes
1answer
36 views

Test Class not sending page reference

I have looked at many examples and even some questions asked in stack but I still cannot get my test class to send the Page reference over. When I look at my log, it shows that it enters my controller ...
1
vote
1answer
23 views

Why doesn't SFDC think my unit test covering the Exception?

I am currently working on unit tests for the following method: @HttpGet global static REST_MemberRestServiceReturnClass doGet() { String[] uriKeysArray = ...
0
votes
0answers
18 views

How to avoid a dealock when setting up custom settings for test data?

We have a few triggers on different objects that depend on a custom setting to exist, so when we create test units on those objects, we need to create that custom setting. We wanted to avoid having ...
2
votes
1answer
31 views

Does Test.stopTest() cause ALL waiting asynchronous functions to fire?

For practice, I'm composing on a unit test for a Schedulable class: /** * Example of scheduling Apex Batch Processing * @see Apex Workbook, page 68 **/ global class WARE_CleanMerchandiseScheduler ...
3
votes
2answers
50 views

How to test with Queues

I wrote a trigger on a custom object, that should be able to handle an user and a queue as owner. In oder to test this i wrote a simple test: Group testGroup = new Group(Name = 'Queue', Type = ...
2
votes
1answer
33 views

How to write a unit test for controller using a field set?

Can someone provide an example of how to write test code for a field set used in a controller? I just need the code showing how to create a field set in the test code, so I do not have to depend on a ...
4
votes
1answer
38 views

Is it possible for an SFDC Apex unit test to parse a debug log?

I'm currently playing around with SFDC-Http Integration and the new Mock server functionality. In the Apex code which I am testing, I have this branch condition: if (response.getStatusCode() != 200) ...
2
votes
2answers
32 views

Code Coverage is including system.debug and comments too

I have a weird situation, in one of my class code coverage is calculated including system.debug statements and comments too. Any clue what might be causing this?
1
vote
2answers
25 views

Trigger Test Class and Code Coverage

Need assistance to identify what's needed to obtain better coverage, which is currently 62%. Lines 12, 13, 17, 18, 23, 27 are all not covered. To note: I have not included any references to Contact__c ...
3
votes
0answers
33 views

Lead.IsConverted shows false in test class

Lead.IsConverted shows false in the test class. Lead leadRec = new Lead(); leadRec.Account_Groups__c = 'Test;Test1'; leadRec.RecordTypeId = RecType; leadRec.lastName = 'Karthik'; ...
1
vote
0answers
44 views

See the code coverage of my package without uploading it

I have a packaging org of a managed package and only 60% of its classes are actually part of my managed package. How or where can I check the code coverage of only those packaged classes without ...
2
votes
0answers
44 views

UNABLE_TO_LOCK_ROW Custom Setting Parallel Apex Testing Summer '13 (28.0) Regression

All of my classes, triggers, pages, components are set to API Version 28.0, Summer '13. None of my test classes/methods use SeeAllData=true annotation. Most of my test classes/methods insert ...
2
votes
2answers
39 views

Create Task Activity in Unit Test

I am apparently missing something in the creation of my unit test data. I would like to create both an Account and an Open Activity (task) for the account. I am able to successfully insert both ...
2
votes
0answers
39 views

Get Status Updates When Running Tests with ANT Migration Tool

I'm trying to set up Jenkins to automate a daily task of running all tests in my sandbox (and eventually, production environment. Typically, when I do a deploy or retrieve task, I get lots of output ...
2
votes
1answer
50 views

Update Trigger doesn't fire in testMethod

Basically, I've written a trigger that will update a custom field on an User object when the value of a standard field changes. The trigger works when it is "triggered" via actions made by me on the ...
5
votes
1answer
60 views

HttpCalloutMock Interface where there is more than 1 callout

Here is some background- I have an apex future method which is being called from an trigger. The future method then performs 3 different http calls to an external system (same endpoints). All requests ...
3
votes
2answers
62 views

Getting CalloutException when testing Batchable class with Callouts and HttpCalloutMock

I'm trying to write test code for a Batchable class that AllowsCallouts. I've written a lot of other test code that uses HttpCalloutMock classes, and planned to do so for this class as well. And, ...
0
votes
0answers
21 views

System.UnexpectedException: Error processing messages

Yesterday I was running my unit tests with no errors, but my latest execution gave me the error: "System.UnexpectedException: Error processing messages". Today I tried again getting the same issue. I ...
1
vote
1answer
28 views

SeeAllData and test data isolation across user profiles

My question is about a strategy for unit testing across profiles. Ideally, we'd like to isolate data to our unit tests (SeeAllData=false, the default) so that we could more easily write our unit tests ...
1
vote
1answer
39 views

Test Class update to Opp Owner causing DML Exceptions

I've been pulling my hair out trying to resolve a problem with a test class for a trigger that fires on update of Opportunity. When the Opp Owner is updated, the trigger updates the Owner of related ...
5
votes
1answer
88 views

How to test if outbound email is send

I have a batch that sends out an email notification to the triggering user when something went wrong. The code that does this is called from the finish() method. I'm now looking for an elegant way to ...
5
votes
1answer
46 views

Does setting up a test fixture contaminate your database?

I'm learning how to write tests to improve the code coverage of my Apex classes. In the official documentation on the subject the examples show how a test fixture is set up before the test to make the ...
2
votes
1answer
47 views

How Run Tests in Default namespace for sandbox using Ant

I am planning to run SFDC tests for Default namespace in sandbox my build file is as follows - <target name="RunTestDefaultNamespaceSandbox"> <sf:compileAndTest username="${sf.username}" ...
1
vote
1answer
61 views

How do you access a wrapper class from a Test class?

I have a VisualForce page which uses a controller. Within the controller I have a couple of wrapper classes which hold various form elements on the page. Everything works great, but now it is time ...
2
votes
2answers
50 views

Need help with an Apex trigger

I have a junction object with two master detail relationships. One to contacts and one to a custom object named program. I created the following trigger to avoid duplicates but im having A LOT of ...
3
votes
2answers
55 views

Trigger only updates on odd numbered input and not even

trigger trig_Opportunity_CreateOppOwner on Opportunity (before update,before insert) { List<id>OppsID = new List<id>(); //List that will hold all id of all new Opportunities owners ...
1
vote
1answer
83 views

Covering if-else conditions in a Testclass

I'm having a save method with several Conditions in it.Here is my apex class invoiceset = [select SiteUrl__c, ...
5
votes
3answers
85 views

Randomizing User class username

I have the following method: public static User initUser(){ /** * Create a User * Insert User into DB * Return User back into testPage in order to use information **/ User ...
2
votes
1answer
106 views

Getting a System.DMLException:Insert failed error

I"ve created a trigger which is relatively short trigger trig_Opportunity_CreateOppOwner on Opportunity (before update,before insert) { List<id>OppsID = new List<id>(); //List that ...
2
votes
2answers
34 views

Creating a test for my trigger, need help on the cases to check

trigger trig_Opportunity_CreateOppOwner on Opportunity (before update, after insert) { List<id>OppsID = new List<id>(); //List that will hold all id of all new Opportunities owners ...
6
votes
4answers
81 views

How can Document folder be created in unit tests?

Can Document folders be created in unit tests? If not, is there a simple workaround for testing Document objects in unit tests?
2
votes
2answers
34 views

How can Email Template be created in unit tests?

Can I create an Email Template as part of the unit test? If yes, how?
2
votes
1answer
48 views

PushTopic Test: Duplicate Name Bug?

I am writing a test class for a utility class for inserting PushTopics. Despite explicitly setting @isTest(SeeAllData=false) on my test class, I am getting a System.DMLException because of a ...
4
votes
1answer
52 views

Is there any way to unit-test that a function will run into a LimitException?

I need to write a test that verify that a function call is run synchronously. As I have found no elegant way to find that out I now let my function run into a Limit which is an indirect proof that ...
2
votes
0answers
84 views

RECORD_IN_USE_BY_WORKFLOW, Unable to convert lead that is in use by workflow: []

In my Apex class i am converting leads. When i test my code through UI it is working fine but when i run my test class it get failed and shows this error: 22:21:47.413 ...
2
votes
1answer
127 views

Trigger Test Class update error

I'm having some difficulties with a test class I'm writing for an Apex Trigger. When I test the trigger manually, I have no problems. Everything works perfectly! However, in my test class, I'm having ...
2
votes
3answers
142 views

Visualforce Error Handling Test Exception

I am looking at testing the following exception message. public static void addError(String msg){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, msg)); } public ...
0
votes
1answer
60 views

Trigger Testing Question

I've written a simple trigger that updates a field on child Contact records when a specific field in the parent Account record is modified. When I test it manually, it works beautifully! However, I'm ...
3
votes
1answer
59 views

Owner is null after insert - Test class

I have to test the results of a query like this: [SELECT Id, Owner.Name FROM MyObject__c] which is called in the constructor of a visualforce page. The Owner.Name is diplayed in the page. The page ...
0
votes
0answers
74 views

Test Class Code Coverage Issue : System.QueryException

My Apex class is Class1: Public class myclass{ //some code public void save(){ invoice_policy__c inp=[select ...
2
votes
2answers
128 views

Custom Objects Related to Lead associate to Account/Contact/Opp during Lead Conversion

We have several custom objects that can be related to Leads and that should end up related to the resulting Account/Contact/Opp during Lead Conversion. These Objects have multiple Lookup fields on ...
0
votes
1answer
444 views

Test Class for a Wrapper class when Checkbox is true

My Apex Class is Public class Myclass{ public class tempconwrapper{ public boolean selectedcheck; public void setselectedcheck(boolean b){this.selectedcheck = b;} public boolean ...
1
vote
1answer
137 views

Writing trigger test to test if custom object was inserted/updated

I am writing an after insert, after update trigger for a custom object CustomA_c. On changing the status field of this custom object to some value I need to create another custom object CustomB_c and ...
0
votes
3answers
78 views

How to create a custom field in test class

I have a custom setting which holds all the fields of an object. If i created a new custom field on the object it is need to get inserted into custom setting and for this i have written code which is ...
4
votes
5answers
772 views

How to write a unit-test / test class for trigger?

This Question is designated to become a community wiki - please add info, your guides and points, step-by-step procedure, as the subject deserves it. How do I write a unit-test / test class for a ...
7
votes
1answer
112 views

Is a TDD approach feasable on Force.com?

I recently tried to do TDD (test driven development) on Force.com and hit a limit that seems to contradict my understanding of how Salesforce.com wants us as developers to work. What I just did was ...
-1
votes
2answers
83 views

How to move from development to production [duplicate]

Hi We have some development in our org. Now we want to move this development to production. How to do this, i bit confused in this. Can anyone tell how to move from development to production. Thanks, ...

1 2 3 4