New answers tagged unit-test
0
votes
VS Code SFDX Unit Tests: Cannot see "Run Test" or "Run All Tests"
I had the "Run Test" and "Run All Tests" tags disappear because the Salesforcedx-vscode-apex › Java: Memory was too low for an Org with a lot of Apex.
Increasing the Memory size to ...
0
votes
Unable to fetch accountId of User in Test class
The issue is here:
User u = TestUtility.createCommunityUser(con.Id,profileId,'Fname','Test');
that calls
public static User createCommunityUser(String contactId, String profId, String firstName, ...
0
votes
How to properly test and assert an @restresource that do multiple API calls?
we can acheive this using map of callouts.
Below article clearly explained the way how to do that
https://developer.salesforce.com/blogs/developer-relations/2013/03/testing-apex-callouts-using-...
2
votes
Need help increasing the code coverage for this trigger
Some background
The golden rule of unit testing is
You only gain coverage for lines of code that are executed by some test method
In tests, we are the ones responsible for setting up the test data. ...
0
votes
ContentDocumentLink Trigger successfully blocks file upload on Org but fails in Dev Console
I was able to recreate your issue in a sandbox but was unable to resolve it while keeping addError(). addError() was not throwing an exception in the unit test. Maybe someone else can recommend how to ...
0
votes
Accepted
force:apex:test:run throws error in CI: "No tests were able to be executed on the org. Please verify that the source code has been pushed correctly"
About 12 hours later and the error is gone.
No changes were done to code/org settings from my side.
Those are the mysterious ways of Salesforce, I guess :)
0
votes
B2B Commerce: Error getting or creating webcart
You will need to assign the buyer group to the WebStore by creating a WebstoreBuyerGroup record.
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/...
1
vote
Apex - 0% Code Coverage!
Solved. The FundingAwardTriggerTest test class was omitted from my outbound change set. Including it solved the issue!
2
votes
"Connection was cancelled here" error NOT related to parallel testing
Since this seems to be related to coverage data, I tried clearing all test data (Dev Console > Test > Clear Test Data, then querying ApexCodeCoverageAggregate using ToolingAPI and deleting all ...
1
vote
Accepted
Apex Mocks - Verify that child is correctly related to a previously registered parent in Unit of Work
Since it is unit test code, you should know how many Contacts will be added to the same parent account
Thus, your ApexMocks verify for
unitOfWork.registerNew(new Contact(
...
Top 50 recent answers are included
Related Tags
unit-test × 4708apex × 2946
code-coverage × 818
trigger × 561
failing-tests × 314
class × 207
batch × 196
visualforce × 185
callout × 128
test-setup × 119
soql × 118
deployment × 114
controller × 109
httpcalloutmock × 108
scheduled-apex × 87
community × 56
exception × 55
lightning-web-components × 52
rest-api × 48
webservices × 48
controller-extension × 47
error × 44
future × 44
managed-package × 42
salesforcedx × 39