Testing, Debugging, and Deployment (17%) Flashcards
Can anonymous code be executed to test Apex classes?
NO!
Major differences in executing Apex code anonymously and in unit tests:
- Anonymous code commits data changes to the system.
- Anonymous code does not provide code coverage.
- Anonymous code is executed in user mode with sharing enforced.
- Anonymous code is not saved or stored, even when executed (but it will generate a debug log!)
- Anonymous code does not reset governor limits if startTest() and stopTest() methods are used.
Proper procedure for unit testing
- Create test data
- Call the Apex class method in the test method
- Verify results
What are the different tools you can use to run Apex test methods?
- Developer console
- Salesforce UI (Apex Test Execution in Setup)
- VS Code
- SOAP API
What groupings of unit tests can you run?
- Some or all methods in a specific class
- Some or all methods in a set of classes
- Test suite (predefined suite of classes)
- All unit tests in your org
What is NOT counted as part of Apex code coverage?
- Calls to system.debug
- Test methods and test classes
What is Suite Manager?
Suite Manager is used to create or delete test suites or edit which classes your test suite contains.
A test suite is a collection of Apex test classes that you run together.
Suite Manager is only used to bundle test classes, not to create or edit them directly.
What does runAs() enforce and not enforce in regards to user access?
- Record sharing settings
- Does NOT enforce user permissions, object settings, or field level security!
- It ignores user license limits
- Can be used with new or existing users
What is a debug level?
A set of log levels for debug log categories
- You can reuse debug levels across your trace flags
What is the Log Inspector?
A context-sensitive execution viewer that shows the source of an operation, what triggered the operation, and what occurred afterward.
Use this tool to inspect debug logs that include database events, Apex processing, workflow, and validation logic.
What information can the Log Inspector contain?
- Stack Tree
- Execution Stack
- Execution Log
- Source
- Variables & Execution Overview
Difference between AsyncApexJob and CronTrigger objects when using a SOQL query to obtain information about a scheduled job?
AsyncApexJob uses “Status”, CronTrigger uses “State”
How often can Partial Copy and Full Copy sandboxes be refreshed?
- Partial copy = 5 days
- Full copy = 29 days
What information does the Checkpoints tab provide?
- Namespace
- Class
- Line
- Time (DateTime)
What type of sandbox should be used for quality assurance tasks like user acceptance testing, integration testing, and training?
Partial Copy
What type of sandbox should be used for performance testing, load testing, and staging?
Full Copy
Common use cases for Tooling API
- Source control integration
- Continuous integration
- Deployment of Apex classes and triggers
- Accessing a debug log
- Accessing code coverage results for an Apex class
- Committing changes to an org
*Tooling API can be used for fine-grained access to the org’s metadata. Simpler migrations should use the Metadata API.
Debug log categories
- Apex Code
- Apex Profiling
- Callout
- Database (DB)
- System
- Validation
- Visualforce
- Workflow
Debug log level options
(in order from least to most information provided)
- NONE
- ERROR
- WARN
- INFO
- DEBUG
- FINE
- FINER
- FINEST
What type of environments can you use to develop a managed package?
- Developer Edition
- Partner Developer Edition
What user is created automatically by Salesforce, where the user detail record cannot be maintained?
Some Salesforce applications automatically run their business processes as it.
Platform Integration User
When does the Platform Integration User show up in audit fields after setting up a trace flag for it?
- When an Einstein bot creates a case
- When Einstein writes prediction data to records it is evaluating
- When data is synchronized using Salesforce Integration Cloud
Capabilities of VS Code
- Test and debug Apex classes and triggers
- Run anonymous blocks of Apex on the server
- Execute SOQL queries
- Synchronize project contents with changes on the server
- Deploy metadata components from on Salesforce org to another
- Projects can work in online or offline modes
When should a scratch org be used?
- To perform automated testing
- To work on a single feature or update
How do you use the “@isTest” and “@TestSetup” annotations?
- Use @TestSetup in a test class to create test data that the rest of the methods in the class will use. Changes made by each method to the test data reset after every method iteration so the different methods are not accessing changes made by each other. @TestSetup cannot explicitly be called by another class.
- @isTest is used to define classes and methods that only contain code used for testing your application. Classes defined as @isTest must be top-level classes. Classes and methods defined as @isTest can either be private or public.