Questions tagged [test-data-isolation]
The test-data-isolation tag has no usage guidance.
25
questions
2
votes
1answer
33 views
My test class (not annotated seeAllData=true) actually sees data for ContentNote SObject
I know test methods should not see any data except the data created in test context, but when I run the test below, the query returns an org record.
It should not
I have a REST class like
@...
0
votes
0answers
19 views
How do you use the PricebookEntryHistory in the Apex Test Class? [duplicate]
How do you use the PricebookEntryHistory in the Apex Test Class? I have a batch job that reads off the PricebookEntryHistory object to check if a field value has changed, and I'm trying to figure out ...
1
vote
1answer
47 views
Updating Object during isUpdate and isBefore trigger
I have a trigger that fires on the event trigger.isUpdate && trigger.isBefore for the Account object. In this trigger, I need to update a field in the Account object. I tried to add an update ...
0
votes
2answers
43 views
A way to put sobjects to a relationship for faking data?
I'm trying to build a database fake using StubAPI to use in Apex tests. I want to do it to save time on Database interaction (no DMLs and SOQLs) and make tests faster.
But I faced an issue with ...
7
votes
1answer
239 views
Unit Testing problem with Product2 records: A Product with this SKU already exists
I'm using the Product object and store the product sku within the StockKeepingUnit field.
According to the Winter 18 release notes, this field is considered unique, which is totally fine and expected ...
3
votes
2answers
604 views
How to use Stub API in the following scenario?
I am trying to understand Stub API a bit:
My Class:
public class DistributedMSelector {
public static Map<string, user> getUserMap(Set<String> employeeIdSet){
Map<String,...
4
votes
1answer
74 views
Testing an approval process - should I create metadata just to test?
I have an Apex test that is testing if a record is in an approval process.
To test, I have to submit a record for approval - but there is no guarantee that there will be an approval process set up in ...
2
votes
3answers
680 views
How do I pass record IDs from testSetup to isTest methods?
I want to create data in a test class that can be used by multiple test methods. However, for the test method to be able to access that test data, I need a way to pass the record IDs to from the @...
2
votes
0answers
40 views
Workflow rule has access to Org data when running in a test context
I have an interesting situation, and I am working a Case with SF Support on. I though I would ask the same question here and see if anyone else has seen something similar.
It starts with a Custom ...
2
votes
2answers
247 views
What is the scope and level of isolation of @TestSetup data in a test class?
I would like to use @TestSetup in my unit tests to create common data for each of my test methods:
@isTest
private class AwesomeTests {
// how many awesome things to setup
static final ...
2
votes
1answer
230 views
MocksApex - behaviour verification
I am using the ApexMocks framework and I am having the following error message:
Class.MockTest.testBehavior: line 13, column 1 11:53:56.3
(10709808)|FATAL_ERROR|System.NullPointerException: ...
7
votes
2answers
989 views
Writing tests for Managed Package
I'm developing a managed package and I need to implement some test classes to test my code. However, I'm not sure how to write my tests in such a way so that they don't break due to custom rules put ...
3
votes
0answers
446 views
Test passes when run alone; fails when run with other methods in the same class
I've got a test that passes when run by itself, but fails when run alongside another method in the same class.
No changes were made between test runs, and I have made sure to select Disable Parallel ...
2
votes
1answer
488 views
Seeing all Territory data in test, but SeeAllData is False
For some reason, am I seeing territory data (Territory2Model, Territory2) in my tests, but I have not set SeeAllData=True and I've even set SeeAllData=False.
Without perform any test setup and ...
4
votes
1answer
504 views
Changing username in Apex Test is emailing the user
I'm testing a controller for a Customer Community page where users can change their email address. To keep things simple for the user, I'm getting the controller to also change their username to match ...
1
vote
1answer
45 views
Data to use in unit tests, how to manage?
while doing unit testing in Salesforce, how do you handle the test data?
Do you make new sets of data each time? (thats what Im doing right now)
Any other suggestions?
On a tangent, how do I ...
3
votes
1answer
384 views
Test coverage for a user trigger: How to prevent “DML not allowed on User” in test-class?
I want to deploy a trigger on user. Therefore I need > 1% coverage on the trigger. To invoke the trigger in my test class, I've tried this:
@isTest public class elfTriggerFrameworkTest {
public ...
3
votes
1answer
546 views
Using Test.IsRunningTest(), Risks and use-cases
Through our testing coverage implementation on a project, we encountered some collisions on a trigger which assigns a Pricebook to a Product and our test data factory (uses "@test setup" tag => no ...
1
vote
1answer
2k views
UserTerritory2Association trigger test
I have a trigger for UserTerritory2Association standard object like:
trigger MyUserTerritoryAssociationTrigger on UserTerritory2Association(after insert, after update,
after delete, after undelete) {
...
2
votes
1answer
739 views
How to catch custom exception in a test that causes a DML exception
I am writing a test for a 'before insert' trigger. In the trigger, an exception is thrown if there is a problem with the validation (by design). In production, the trigger catches the exception and ...
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, ...
2
votes
0answers
416 views
Issue with Query during Test on User Object after Winter 15
Specific example that I did not see in other questions:
Unable to query user object when filtering on ProfileName and Limiting result during test in production
Have a test class passing in full ...
0
votes
1answer
809 views
Test.loadData with sObject Throws Unknown field: Exception
Iam loading a CSV file via Static Resourced to test my APEX code. I am using the following code in my test:
List<sObject> ls1 = Test.loadData(Account.sObjectType, 'TestAccount');
CSV file ...
4
votes
0answers
534 views
S2S Test Data Isolation
Goal - Avoid using SeeAllData=true for testmethods against APEX code that inserts PartnerNetworkRecordConnection objects (to test outbound sharing)
What I believe to be true
PartnerNetworkConnection ...
1
vote
0answers
173 views
seeAllData = false vs. ConnectApi
I have a trigger on FeedItem that auto-tags a topic. It does so by creating a TopicAssignment record and inserting it via DML. The problem is that I am getting a gack if I attempt to auto-assign a ...