Testing, Debugging, and Deployment (17%) Flashcards

1
Q

Can anonymous code be executed to test Apex classes?

A

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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Proper procedure for unit testing

A
  1. Create test data
  2. Call the Apex class method in the test method
  3. Verify results
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the different tools you can use to run Apex test methods?

A
  • Developer console
  • Salesforce UI (Apex Test Execution in Setup)
  • VS Code
  • SOAP API
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What groupings of unit tests can you run?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is NOT counted as part of Apex code coverage?

A
  • Calls to system.debug

- Test methods and test classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Suite Manager?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does runAs() enforce and not enforce in regards to user access?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a debug level?

A

A set of log levels for debug log categories

  • You can reuse debug levels across your trace flags
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the Log Inspector?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What information can the Log Inspector contain?

A
  • Stack Tree
  • Execution Stack
  • Execution Log
  • Source
  • Variables & Execution Overview
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Difference between AsyncApexJob and CronTrigger objects when using a SOQL query to obtain information about a scheduled job?

A

AsyncApexJob uses “Status”, CronTrigger uses “State”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How often can Partial Copy and Full Copy sandboxes be refreshed?

A
  • Partial copy = 5 days

- Full copy = 29 days

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What information does the Checkpoints tab provide?

A
  • Namespace
  • Class
  • Line
  • Time (DateTime)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What type of sandbox should be used for quality assurance tasks like user acceptance testing, integration testing, and training?

A

Partial Copy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What type of sandbox should be used for performance testing, load testing, and staging?

A

Full Copy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Common use cases for Tooling API

A
  • 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.

17
Q

Debug log categories

A
  • Apex Code
  • Apex Profiling
  • Callout
  • Database (DB)
  • System
  • Validation
  • Visualforce
  • Workflow
18
Q

Debug log level options

A

(in order from least to most information provided)

  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST
19
Q

What type of environments can you use to develop a managed package?

A
  • Developer Edition

- Partner Developer Edition

20
Q

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.

A

Platform Integration User

21
Q

When does the Platform Integration User show up in audit fields after setting up a trace flag for it?

A
  • 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
22
Q

Capabilities of VS Code

A
  • 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
23
Q

When should a scratch org be used?

A
  • To perform automated testing

- To work on a single feature or update

24
Q

How do you use the “@isTest” and “@TestSetup” annotations?

A
  • 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.
25
Q

Why would you use @isTest(SeeAllData=true)?

A
  • Use this to grant test classes and individual test methods access to all data in the org, including pre-existing data that the test class didn’t create.
  • If the containing class uses @isTest(SeeAllData=true) then every method in the class inherits that access, even if a method is specifically annotated with @isTest(SeeAllData=false). Conversely, if the containing class is annotated with @isTest(SeeAllData=false), any method within the class can override that access level by using @isTest(SeeAllData=true)
26
Q

Why would you use @isTest(isParallel=true)?

A
  • Use this annotation to indicate test classes that can run in parallel. Default limits on number of concurrent tests do not apply to these test classes. This annotation makes the execution of test classes more efficient because more tests can be run in parallel.
  • @isTest(SeeAllData=true) and @isTest(isParallel=true) annotations cannot be used together on the same test method.
27
Q

How can you make @TestSetup data from one test class visible to another test class?

A

You can’t call @TestSetup explicitly from another test class as it is a system function. @TestSetup is only available to the methods in the class where it’s defined.

However, you can create an @TestSetup method and then call that method from within another @TestSetup method of another class.

EXAMPLE: TestDataFactory is the class that contains the test data we want. The test data in that class is stored in a @TestSetup annotated method called dataFactorySetup().

In a separate test class, TestFunctionalClass, use a method annotated with @TestSetup, prepareData(), to call the dataFactorySetup() method from the TestDataFactory class.

public class FunctionalClass {
    //logic that needs to be tested
}
@IsTest
public class TestFunctionalClass {
@TestSetup static void prepareData()
{
    TestDataFactory.setup();
}
    static testMethod void validateData()
    {
        //unit tests that test FunctionClass logic
        //query for data that is setup in TestDataFactory.class
    }
}
@IsTest
public class TestDataFactory {
    static void setup() {
        //insert test data
    }
}
28
Q

Apex Governor Limits: Maximum number of asynchronous Apex method executions per 24-hour period

A

250,000 OR the number of user licenses in your org multiplied by 200, whichever is greater

29
Q

Apex Governor Limits: Total heap size

A

6 MB, or 12MB asynchronously

30
Q

Apex Governor Limits: Maximum CPU time on Salesforce servers

A

10,000 milliseconds or 60,000 milliseconds asynchronously

31
Q

Apex Governor Limits: Maximum execution time for each Apex transaction

A

10 minutes

32
Q

Apex Governor Limits: What maximum limits can be made greater when methods are run asynchronously?

A
  • Total number of SOQL queries issued
  • Total heap size
  • Maximum CPU time