Testing (10% Weighting) Flashcards

Given a customer scenario, describe and recommend an appropriate testing methodology.

1
Q

What are the three general buckets of software tests?

A

Unit
Functional
Integration

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

Name the 4 methods for creating test data

A

Brute Force
Test Factories
TestSetup Methods
CSV Data Files

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

What is the brute force method for creating test data?

A

Before you call the underlying code that you’re testing, you’re creating the necessary data by creating and inserting objects.

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

What is the drawback from brute force test creation?

A

It can lead to lengthy tests that are hard to follow, especially when you start generating records that are related to other records and contain lots of field details

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

What is the test factories method for creating test data?

A

Move your data creating into a reusable class. They’re called data factories, and they are reusable classes that contain methods that model the creation of one or more objects

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

What is the TestSetup method for creating test data?

A

Multiple test methods in the same class often have similar data requirements. You can annotate these methods in your test class as @testSetup. The platform calls these methods automatically before every individual test method. Because they’re called before every test method in the class, they’re perfect for creating test data. Note that the data is reset in between each and every test method’s execution.

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

What is the CSV Data Files method for creating test data?

A

You can create and upload a CSV file as a static resource and generate test data directly from that CSV

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

What is the typical positive testing pattern?

A
  1. Generate or Load Test Data
  2. Call Test.startTest()
  3. Execute your code
  4. Call Test.stopTest()
  5. Make Assertions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What do negative testing demonstrates?

A

That the code properly handles invalid data, unexpected user input, and changes in other parts of the code base.

More important, it affirms that the code is fault tolerant

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

What is the typical negative testing pattern?

A
  1. Generate or Load Test Data
  2. Call Test.startTest()
  3. Create and set a boolean variable to false
  4. Start a try/catch block
  5. Execute your code
  6. Catch the expected exception, and if the details match, set the Boolean variable to true
  7. Assert that the boolean variable is true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the typical permissions testing pattern?

A
  1. Generate or Load Test Data
  2. Create users with appropriate profiles or permission sets
  3. Call Test.startTest()
  4. Start a System.runAs(user) blck
  5. If you’re writing a negative permission test: Create and set a boolean variable to false
  6. Start a try/catch block
  7. Execute your code
  8. If you’re writing a negative permission test: Catch the expected exception, and if the details match, set the Boolean variable to true
  9. Make assertions about the value or status of fields, objects and caught exceptions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What wrapper libraries does the Lightning Platform app provide for testing JavaScript

A

Jasmine and Mocha

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

The Lightning Test Service provides:
A) A utility $T object

B) Software for automatically generating Javascript unit tests

C) A way to execute Javascript based Lightning Component tests

D) A and C

A

D) A and C

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

When writing Javascript unit tests for Lightning components, the $T object:

A) Creates and modifies instances of your Lightning components

B) Inserts fake values into your Lightning attributes

C) Organizes tests into suites using the describe keyword

D) What $T object?

A

A) Creates and modifies instances of your Lightning components

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

What are the use cases for mock and stub objects (Name two)

A

1: You find it whenever you’re making a callout from Apex to a third-party web service
2: You come across this use case whenever you’re testing code that relies on another object’s internal state or implementation

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

What is the pattern for creating a Mock Object?

A
  1. Create a class that implements HttpCalloutMock
  2. Create or load your test data
  3. Create an instance of your class
  4. Call Test.setMock(mockInstance) - passing in the mock object instance
  5. Call Test.StartTest();
  6. Execute your code that makes a callout
  7. Call Test.stopTest();
  8. Make assertions
17
Q

What is the pattern for creating a Stub Object?

A
  1. Create or load your test data
  2. Create an instance of your class
  3. Call Test.StartTest();
  4. Execute your code you want to test
  5. Call Test.stopTest();
  6. Make assertions
18
Q

When would you do Stress Testing?

A

When you need to gauge performance during abnormal/extreme conditions

Stress testing is not necessary on the Force.com platform because Salesforce has already stress tested the platform so it is not necessary for you to

19
Q

When would you do Load Testing

A

When you need to gauge performance under expected conditions with varying loads

20
Q

What do you need to keep in mind when performing Load Testing?

A
  • Load testing on a sandbox will not provide the same benchmarks as a production environment
  • To do a load test, you must create a “test plan” that you submit to Salesforce for approval
21
Q

What is the metric used for load testing?

A

TPS (Transactions per second)

22
Q

When would you do performance testing?

A

When you need to gauge performance under particular workloads. This includes both stress and load testing collectively.

You can test in a sandbox to uncover conflicts between request (locking issues) or to test performance of external web services.

23
Q

What are Apex Hammer Tests?

A

Salesforce runs your org’s Apex test in both the current and new release and compares the results to identify issues for you

24
Q

What data is displayed on the Apex Hammer Test?

A
  • Date when Hammer was last run in this org
  • Number of Apex tests executed and passed
  • Percentage of Apex tests that are data silo tests
  • Date range when Hammer is scheduled to run next
25
Q

What is a data silo test?

A

A test method that doesn’t have access to org data

26
Q

What are the advantages of creating data silo tests?

A
  • Tests run more reliably because they aren’t dependent on data that can sometimes change
  • Failures from those tests are easier to diagnose
  • Finding bus in the Hammer process is easier
  • Deploying from one org to another is more reliable
27
Q

When do unit tests use org data?

A

When isTest(SeeAllData=true)