Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 18399

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 tests is considered covered. At least 75% of an organization's codebase must be covered by unit tests and every trigger must have at least 1% unit test coverage.

2 votes
Accepted

Cover inside for - test class

It does not appear that you are inserting the User in your test class. You cannot access the Id of the record if it is not inserted. Add this after your user declaration: try{ insert usr; } catc …
Ronnie's user avatar
  • 2,118
0 votes

Testmethod verification that @future published Platform Event

Couldn't you validate it within the future method? I hate putting test validation in classes, but if you need it absolutely.... if( test.isRunningTest() ){ System.assertEquals( 1, Limits.getDm …
Ronnie's user avatar
  • 2,118
1 vote

Issues with Apex Test Class

Let's break this down a little here: 1: first you should be checking if you even supplied a non-null object for entitlementRec Map<String,Object> mapObj = (Map<String,Object>)Json.deserializeUntype …
Ronnie's user avatar
  • 2,118
2 votes

Testing scheduled apex, Class variables seem to change after test

It is poor practice to use seeAllData = true if you can avoid it. You would be best served to use a setup method to create some test data. Setup methods should be annotated with @TestSetup so that you …
Ronnie's user avatar
  • 2,118
0 votes

Code coverage error when deploying to another sandbox, but Salesforce doesn't show which cla...

Tests passing doesn't necessarily mean that you have adequate coverage. You could run in Developer console from the original org and see what your coverage percentage is. If these are not identical or …
Ronnie's user avatar
  • 2,118
0 votes

Test Class - DUPLICATE VALUE?

I would suggest performing a check to ensure that the account does not already exist before trying to perform an insert. Would also suggest if it does exist to set the account appropriately. This is i …
Ronnie's user avatar
  • 2,118
1 vote
Accepted

Test class passing but not getting any code coverage

So it doesn't appear that you're even testing your class. It only appears that you are testing the trigger, kind of, but never actually testing the class. To properly test your class, you should creat …
Ronnie's user avatar
  • 2,118
1 vote

Test class for Scheduled Batch class making a callout in the start method

You will need to set a Mock response for your callout. Use Test.setMock() method to return your mock response. Refer to documentation HERE for the usage of Test.setMock(). While this is great if y …
Ronnie's user avatar
  • 2,118
2 votes
Accepted

Make the test work: File insert, check this File

So your test class doesn't even use this "FileUploadController" at all from what i see in your post above. What you will want to do is write test coverage that makes use of your Extension and will c …
Ronnie's user avatar
  • 2,118