Testing Flashcards
What does testing framework allow us to do?
Write unit tests
What do test classes contain?
test classes contain unit tests
What are unit tests?
methods that verify a specific piece of code is behaving correctly
How should we name our test classes?
Name them after the class (for example: AccountTriggerHandler - AccountTriggerHandlerTest)
Test Methods
- Take no Arguments
- Return no Values
- Must be Static
What are the Asserting Values for Test Methods when writing system class methods?
- Assert
- assertEquals
- assertNotEquals
Data in Test classes cannot by default do what?
by default, you cannot access org data
you can give access, but should avoid doing so
When is TestSetup executed?
TestSetup is executed before each individual method
SOQL will only return what?
SOQL will only return records generated in the method or in the test method
SOSL will return what?
SOSL will return an empty list
What do Test Utility Classes have?
Test Utility Classes have reusable code that can be called by multiple test classes
What is TDD?
Test-Driven Development
It is a process that has use cases or requirements that are turned into test classes.
What are the disadvantages of Manual testing?
It is inefficient since you act as an end user and have to go through the same process each time
Why do we write unit tests for our code?
It ensures that our code meets the quality standards and produces the results needed for our production.
Allows code to be routinely tested whenever an update happens to ensure there is no code regression.
What is some best practice to follow when writing test code?
It is recommended to write test code for one piece of our application at a time. We don’t want to write test code for our entire application at once.
What is the @isTest annotation?
signifies that an apex class is a test class or that an apex method is a test method
test methods are contained within a test class using the @isTest annotation
Where is the @isTest annotation used?
In an apex test method and an apex test class
What is a naming ‘best practice’ for test classes and methods?
Name the test class and method after the class and method that is being tested. (ex: ApexClassName - ApexClassNameTest)
What are asserting values?
System class methods that are used in test classes and don’t return a value.
What should be your first choice of tool when it comes to testing?
Dummy data to make sure your tests are testing the right functionality
What is a common term for dummy data?
CSV of data
A Utility class can be used by…
multiple test classes as opposed to being called by only a single class.
What does @testVisible do?
Makes private class members accessible by test classes
@isTest(seeAllData=true)
- by default is set to false,
- setting it to true gives test access to your org