Questions tagged [test-setup]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
51 views

Test Class Strategy

I have an Apex Trigger: Trigger CalculateACV on SBQQ__DiscountTier__c (after insert, after update) { (new ExpansionTierCalculator()).calculate(Trigger.new); Tier } ExpansionTierCalculator has ...
5
votes
1answer
1k views

Create Quote related to Account in Test setup method

I'm trying to assign account Id to quote, but i can't even compile code, becouse of this error message: Field is not writeable: Quote.AccountId Sample code: Account acc = new Account(name='Test Acc')...
0
votes
1answer
438 views

STANDARD_PRICE_NOT_DEFINED for more than 1 currency

I tried to populate PriceBookEntry for different currency in test class.It works for only one for one currency, when i try to add different currency it fail. System.DmlException: Insert failed. ...
3
votes
2answers
543 views

Invoke Test Execution (Run Test) using Apex Code [closed]

I don't want to run the apex code using the traditional approaches provided by the salesforce. I want to run the apex test execution using the Apex Code. Is there any way to do it? And in which ...
0
votes
0answers
1k views

StackTrace - External Entry point

When I run my test class by using a method marked with @testSetup annotation, I get into nullPointer exception and the stack trace is shown as - "External Entry Point". Suprisingly when I move the ...
3
votes
1answer
738 views

How to share an object between test methods?

I get System.NullPointerException: Attempt to de-reference a null object when I try to do the following: @isTest private class MyControllerTest { static MyController controller; @testSetup ...
4
votes
1answer
2k views

Test Data Factory Methods counting against code coverage

I have created a Test Data Factory helper class to create Test Data for testing my apex code like suggested in the documentation here: https://developer.salesforce.com/docs/atlas.en-us.200.0.apexcode....
2
votes
1answer
597 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
581 views

run all test in production

Does using Run all test in Production impacts or triggers anything unusual? Will there be any impact on clicking Run all test. I would like to move some code from Full to prod. in FUll it shows 82% ...
0
votes
1answer
43 views

How to centralize setup of testdata to be shared across multiple testmethods

I'm quite tired so I don't know if the title makes sense, but basically I have written a test with two test methods. However in these methods I have to create and insert the Lead set-up first which is ...
0
votes
1answer
549 views

How to refer to a record in @testSetup in a later test method?

I have the following setup method: @testSetup static void settingUp(){ Case exampleCase = new Case(Status='Imminent'); insert exampleCase; } static testMethod void testStatus(){ Case c = [...
-1
votes
1answer
64 views

Simple testing question related to inserting and updating of custom object data and persistence of the data post-test run

I am new to SF coding and I have a fairly complex Apex class that takes a bunch of data and uses it to generate data into a new custom object. This is not a trigger but meant to be a scheduled batch ...
2
votes
1answer
40 views

Feedback on Test for Simple Trigger

I'm a newbie to Apex and can't say how much I appreciate this Board. I have a simple Trigger set up to update the Description fields on the Opportunity Object. I need to write a Test to cover the ...
2
votes
1answer
202 views

How do I Assert in a CanvasLifecycleHandler test class

I have a CanvasLifecycleHandler thst rewrites the url with a timeStamp. Is it possible to assert in the test class that the url has been changed? If so, how? CanvasLifecycleHandler public ...
0
votes
1answer
129 views

Losing all test coverage when testing individual class

I am writing tests for my apex classes. Usually I can test each test class individually from the developer console. When I run the idividual test my code coverage is 0% even if the class passed. My ...
3
votes
1answer
192 views

fixedSearchResults set in @testSetup method, but cannot access in testMethod

I'm new to salesforce, but have been given a task that I am puzzled on. I am given a test class with an @testSetup method which inserts relevant data for the test methods. In my test method, SOQL ...
2
votes
1answer
331 views

Salesforce Calculates Test Coverage incorrectly if classes call each other - how to work around?

Assume you have 2 classes, A and B, each with 10 methods of equal length. You write 2 test classes, TestA and TestB, each running all 10 methods and producing 100% coverage. However, when run from ...
6
votes
1answer
352 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 ...
4
votes
1answer
612 views

Salesforce System Error when using Test.loadData for User.sObjectType, improvements of Test.loadData with custom code

I'm starting to use Test.loadData and am facing an issue when creating Portal User data. Code below works very well, not only creating and inserting Accounts and Contacts, but also establishing proper ...
8
votes
3answers
11k views

Retrieving records from @testSetup Method

I'd like to create records in @testSetup for my Test Class, to avoid the need to create the same records for each of the methods in the class. I also need to create both a User record and Custom ...
-2
votes
1answer
60 views

Writing a test class for methods

I am having troubles figuring out how to write the test class for the following method in my class. Any help would be greatly appreciated. public Oppty_Search_IntegrationOperation....
1
vote
1answer
238 views

Please help write a Test Class for method

I am having difficulties writing a test class for the following method of mine and any help would be greatly appreciated: //Method to filter opportunities based on SalesRep access private Map<Id, ...
0
votes
2answers
51 views

Testing a List “Searchable” Controller

Will someone please explain, or correct, my testing logic for the following code? The first image is the test, and second image is the code. Here's the test Here's the code Here's the code again, ...
0
votes
1answer
426 views

Help with test classes for VisualforcePage Redirect controller

I'm very new with apex, and having a lot of trouble getting code coverage for my tests. Here's my Visualforce page: <apex:page standardController="Task" > <apex:enhancedlist type="Activity" ...
19
votes
1answer
4k views

How do governing limits work with @testSetup from Spring 15' release

The new @testSetup method is covered pretty well by Jesse Altman in his: New Spring ’15 Feature: @testSetup article but as mentioned in the comments, there is a question about how this new feature ...