Questions tagged [test-data-isolation]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
0answers
30 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
110 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
57 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
238 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
35 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
222 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
212 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: ...
6
votes
2answers
646 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
357 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
382 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
374 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
351 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
473 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
1k 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
665 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
397 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
719 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
501 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
160 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 ...