Testing (10% Weighting) Flashcards
Given a customer scenario, describe and recommend an appropriate testing methodology.
What are the three general buckets of software tests?
Unit
Functional
Integration
Name the 4 methods for creating test data
Brute Force
Test Factories
TestSetup Methods
CSV Data Files
What is the brute force method for creating test data?
Before you call the underlying code that you’re testing, you’re creating the necessary data by creating and inserting objects.
What is the drawback from brute force test creation?
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
What is the test factories method for creating test data?
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
What is the TestSetup method for creating test data?
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.
What is the CSV Data Files method for creating test data?
You can create and upload a CSV file as a static resource and generate test data directly from that CSV
What is the typical positive testing pattern?
- Generate or Load Test Data
- Call Test.startTest()
- Execute your code
- Call Test.stopTest()
- Make Assertions
What do negative testing demonstrates?
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
What is the typical negative testing pattern?
- Generate or Load Test Data
- Call Test.startTest()
- Create and set a boolean variable to false
- Start a try/catch block
- Execute your code
- Catch the expected exception, and if the details match, set the Boolean variable to true
- Assert that the boolean variable is true
What is the typical permissions testing pattern?
- Generate or Load Test Data
- Create users with appropriate profiles or permission sets
- Call Test.startTest()
- Start a System.runAs(user) blck
- If you’re writing a negative permission test: Create and set a boolean variable to false
- Start a try/catch block
- Execute your code
- If you’re writing a negative permission test: Catch the expected exception, and if the details match, set the Boolean variable to true
- Make assertions about the value or status of fields, objects and caught exceptions
What wrapper libraries does the Lightning Platform app provide for testing JavaScript
Jasmine and Mocha
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
D) A and C
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) Creates and modifies instances of your Lightning components
What are the use cases for mock and stub objects (Name two)
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