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
1answer
19 views

compile error in test class

@isTest private class methodonetest { private static Account acc; private static Opportunity Opp; private static Quote Q; private static Product2 prd; private ...
0
votes
1answer
13 views

How to fix test class for selectionoptions?

Hi I'm trying to write a test class for this controller class but the code is getting an error. This is my controller class: public class AccountRelatedContacts { public id tobeEdited{get; ...
0
votes
1answer
24 views

Apex test method for wrapper classes

I looked at these existing questions but they didn't answer my specific case: Writing test code for wrapper class Writing Test class for Wrapper Class in my controller I have the below code which ...
1
vote
1answer
11 views

testing future with callout from schedulable class

I'm definitely missing something. How do I test Schedulable class with a future method that does a callout?I have 100% code coverage of the Schedulable class but 0% of my service.The test fails as no ...
0
votes
1answer
46 views

Code Coverage Issue on trigger

I have a trigger and an apex class, When i deploy them from staging to production I get the following error. What Should i do ? I have a week experience in salesfroce. Issue Code Coverage Failure ...
0
votes
1answer
14 views

System.TypeException: Cannot call test methods in non-test context

Hi i have a test class but it gives following error error : Line: -1, Column: -1 System.TypeException: Cannot call test methods in non-test context Code @isTest public class testclass { ...
0
votes
1answer
23 views

How do I write a proper test for my trigger?

I am new to apex and I've written a trigger to update the Account Manager (user lookup field) to be the same as the Account Owner when certain circumstances are true. I've manually tested it and it ...
2
votes
1answer
14 views

Do Unit Tests Increment Auto Number Fields?

I just created a new object with an auto-number name field. Its Starting Number is 0. I ran many unit tests before creating any data, and the true Starting Number I observed is 1420. Is this ...
0
votes
0answers
18 views

Help with test code for a class and trigger [on hold]

I have an Apex class which is a VF controller and a Trigger which will work on the same object. I'm trying to write the test code for them and am not getting anywhere. I've never written test code ...
0
votes
1answer
12 views

Bulk Testing with Static Resources

Our team is integrating static resources into our unit tests and were not sure about bulk testing. I have a couple of questions: Would bulk testing be done through code or through adding additional ...
2
votes
2answers
48 views

Assertion failure that a null pointer exception is caught

I am doing some test code right now. In my Apex code I have a method that try-catches a DMLException and afterwards does a general Exception catch. In my test code I am successfully managing to test ...
1
vote
2answers
111 views

Unit Test Trouble. Method does not exist or incorrect signature.

Im sure it's something dumb, but I have spent way too much time on this today. Class public with sharing class CaseCommentExtension { private final Case caseRec; public CaseComment comment ...
0
votes
1answer
22 views

Can we make the alignment of VF page sections dynamic with bootstrap?

I have a requirement where I am overriding the Edit and New page for a standard sObject. I have used a custom settings for page section header and page section's fieldsets. I can iterate over these ...
0
votes
1answer
11 views

How to assign value to html input in test class [on hold]

I am writing test class in my controller extension. In my vf page i am using one html input based on that i am doing some operation. Now i want to assign some value to this html in my test class. How ...
4
votes
2answers
34 views

Cannot get Unit Test to pass in order to push trigger to production

I'm having difficulties creating a Unit Test for an Apex Trigger to pass so I can push the trigger into production. I'm hoping someone can help me or point me in the right direction to where I'm ...
1
vote
2answers
26 views

assertion error with timezone in unit test

I have a unit test that is passes when the user running the test is in the CST timezone, but in any other timezone, the unit test fails with the assertion error: Assertion Failed: Expected: 2014-05-19 ...
3
votes
0answers
18 views

Lightning ODATA connect How to create a Test coverage case

I have tried to create a test coverage method against a database Query which goes after an external object. the external datasource is a Lightning ODATA 2.0 connector. I setup the Mock ...
0
votes
1answer
42 views

CaseTeam Test Code Coverage 63% coverage HELP

I have the following CaseTeam Trigger and CaseTeam Trigger Test Class... it runs but it is only providing 63% code coverage... can you please show me how I can increase my code coverage for this ...
-1
votes
0answers
25 views

How do i increase my code coverage from 52% to at least 75% [closed]

global class ImagesController { global String jsonRequestString {get;set;} ImageResponseWrapper responseWrapper = new ImageResponseWrapper(); //Build the request object ImageRequestWrapper request = ...
3
votes
0answers
19 views

Test class completes successfully in production AND newly refreshed sandbox, but fails on deployment

We have some custom code from before I joined the company that is showing some unusual behavior. Code was somehow successfully deployed to production (before my time), and the test code passes ...
0
votes
1answer
44 views

Error when trying to run a test class on a trigger Eclipse - Force.com IDE

Team, ran the test via the run configuration but am getting the below error. Error: Try running the test again if that doesn't work, run the test from Apex Test Execution in Setup or from the ...
2
votes
1answer
23 views

Test Class Data Setup - Governor Limits

The test method gets its set of governor limits, exclusive of the content between startTest and stopTest. I have faced the issue of 101 SOQL Governor Limits in test classes and mostly I have been able ...
0
votes
1answer
47 views

Need help to increase code coverage for trigger , presently only 42% achieved

Below is the trigger: trigger t_DisableAttachements on Attachment(before insert,before delete,after update) { Id devRecordTypeId = ...
0
votes
2answers
65 views

Unable to cover Test class on Approval process. 69% covered only

public with sharing class T_ApprovalUnderConditionClass { public string comments{get;set;} public Opportunity oppty {get;set;} private string id; private List<Id> prosInsIds = new ...
1
vote
1answer
26 views

Test Class for Approval Process

I am trying to set up a test class to test a Visualforce page button which, when clicked, submits a custom object record to an approval process using a controller method. When I try the test below, I ...
0
votes
0answers
33 views

Test class on User is failing [closed]

Test class is testing region adder trigger where trigger will update full country name to country ISO code and update Region__c based on country name (Geography__c) I created new user and kept all ...
1
vote
1answer
74 views

unable to get code coverage for my apex trigger

Hey i am new to salesforce. I write an apex trigger in lead.Whenever any lead is converted type picklist(standard field) in opportunity object has to updated with new-business.I had successfully wrote ...
0
votes
0answers
14 views

How to succesfully test AgentWork trigger?

I am using AgentWork trigger in my logic and I cannot achieve code coverage goal. Simple test method: Id cId = [SELECT Id From Case Where Subject = 'Case Subject'].Id; User u = [SELECT Id From User ...
0
votes
0answers
32 views

Trigger.old and Trigger.old values are same in Apex class, trigger is running on a frame work

I have a trigger which runs on a frame work and have booleans defined to stop the recursive firing, when writing the test class. i found that System asserts are passing but the ownership change is not ...
1
vote
0answers
58 views

how to call map method in test class can anyone give me some idea [closed]

how to call map method in test class can anyone give me some idea public Map<EnrolmentForm__c, List<String>> EFProcess(EnrolmentForm__c EF_Record) { //logic here } } public ...
2
votes
3answers
53 views

Error: No more than one executeBatch can be called from within a testmethod

I have one batch class which has almost 6k records.I have written test class for the same.But i am getting error saying No more than one executeBatch can be called from within a testmethod. ...
1
vote
2answers
34 views

test class for trigger

trigger updatepipelineamountField on Opportunity (after update) { Map<Id,Decimal> budgetIDTotalMap = new MAp<Id,Decimal>(); set<id> setbudgetId = new set<Id>(); for ...
0
votes
1answer
29 views

Test Class not Retrieving What's Expected

In my controller I have a List: public List<ts2__Job__c> uaVacancies { get; set; } And a simple function to query: public PageReference getUAVacancies() { uaVacancies = [SELECT Id, ...
0
votes
1answer
27 views

My method is failing in test

List<Contract> contracts = new List<Contract> { new Contract( AccountId = DB.getAccountByNUID('800000004').Id, Academic_Year__c = '2020-2022', ...
1
vote
4answers
75 views

Selenium Testing - Two Factor Authentication Problems

First time trying the forum, but today having trouble running selenium scripts with Salesforce. Everytime Im running a script locally I get a two step verification screen. I then have to input the ...
0
votes
1answer
27 views

Unit testing code which has logic around last login date of user

I need to write unit testing code which has logic around system field last login date of user.As per spring'16 release salesforce has added method for setting created date like below. ...
0
votes
0answers
28 views

Unit Test for contentDocument

I am having some difficulty understanding how to design a unit test that works with content documents, particularly when they are attached to records. The use case I have is we want to protect all ...
0
votes
1answer
20 views

Need to cover Else if part in test class

I covered 1st six condition but after that i am not able to increase my code coverage.Plz help. Apex class: if(acc1.Domain_Name_Number__c == 0 && acc1.Subscription_Age__c == 7 && ...
0
votes
1answer
12 views

How can I improve the test coverage of MetadataService.cls (recent Version for API v35)?

I'm using the APEX wrapper for Metadata API found here https://github.com/financialforcedev/apex-mdapi Looking at the test coverage, there are a lot of lines uncovered. Can this be improved easily?
1
vote
1answer
18 views

Error for Test Class on Controller

I have a pretty simple test class on a controller, which worked fine in my developer environment. However, I am now moving it to a sandbox and I'm running into an error: System.DmlException: Insert ...
1
vote
1answer
25 views

Help writing a simple APEX Trigger Test

Sorry, this is probably a really simple question, but I'm struggling to wrap my head around writing a test for my trigger which will allow me to get the required amount of code coverage to push into ...
-1
votes
0answers
31 views

Error while running test classes

@isTest public class TestEnrolmentFormWarningPageController { static testmethod void validateStandardController1(){ Profile p = [SELECT Id FROM Profile WHERE Name='RMS Developer']; ...
2
votes
0answers
28 views

update LastModifiedDate audit field for test class?

is there any way to update the LastModifiedDate audit field for test coverage.
3
votes
2answers
40 views

How to use Dependency Injection while testing

I've been trying to create a job that while working on my test class I should be able to pass 2 lists and the job work work on those lists but once I deploy my code, it should work using my real data. ...
0
votes
2answers
22 views

How do i Assert in this test class

I have a test class and when i gave the package for the security review the message was This rule identifies Apex Test Methods that do not Assert that the code behaves properly. Verifying that ...
0
votes
1answer
33 views

Test Class for SOQL Query Apex Class

I have created an apex class that queries three objects to create a list of records. I use this with a Visualforce page to display a table. It works just fine however my test class isn't giving me any ...
10
votes
3answers
189 views

Apex Test Suites - Spring 16 release

Salesforce defines Test Suite as a predefined-set of test classes that you can execute at once. Can I use a single @testSetup method to set up the test data for all test methods in one Test Suite? ...
0
votes
1answer
12 views

Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>(List<Partner__c>)

I'm trying to write an apex test class for my apex (extension) of my visualforce page which display list of partners from partner__c sObject and do some actions on its rows like edit and delete. ...
0
votes
0answers
43 views

Is there a way to test a user using a page twice simultaneously?

I am developing a system in which a user will use a type of currency to buy access to certain parts of the system. Now i am struggling with the idea of a user using two browsers at the same time to ...
1
vote
1answer
66 views

Trailhead : Apex Integration Services System.QueryException: List has no rows for assignment to SObject

I am working on Trailhead module for Apex Integration Services. Class code @RestResource(urlMapping='/Accounts/*/contacts') global class AccountManager { @HttpGet global static Account ...