Testing Flashcards

1
Q

What does testing framework allow us to do?

A

Write unit tests

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

What do test classes contain?

A

test classes contain unit tests

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

What are unit tests?

A

methods that verify a specific piece of code is behaving correctly

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

How should we name our test classes?

A

Name them after the class (for example: AccountTriggerHandler - AccountTriggerHandlerTest)

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

Test Methods

A
  • Take no Arguments
  • Return no Values
  • Must be Static
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the Asserting Values for Test Methods when writing system class methods?

A
  • Assert
  • assertEquals
  • assertNotEquals
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Data in Test classes cannot by default do what?

A

by default, you cannot access org data

you can give access, but should avoid doing so

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

When is TestSetup executed?

A

TestSetup is executed before each individual method

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

SOQL will only return what?

A

SOQL will only return records generated in the method or in the test method

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

SOSL will return what?

A

SOSL will return an empty list

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

What do Test Utility Classes have?

A

Test Utility Classes have reusable code that can be called by multiple test classes

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

What is TDD?

A

Test-Driven Development

It is a process that has use cases or requirements that are turned into test classes.

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

What are the disadvantages of Manual testing?

A

It is inefficient since you act as an end user and have to go through the same process each time

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

Why do we write unit tests for our code?

A

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.

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

What is some best practice to follow when writing test code?

A

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.

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

What is the @isTest annotation?

A

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

17
Q

Where is the @isTest annotation used?

A

In an apex test method and an apex test class

18
Q

What is a naming ‘best practice’ for test classes and methods?

A

Name the test class and method after the class and method that is being tested. (ex: ApexClassName - ApexClassNameTest)

19
Q

What are asserting values?

A

System class methods that are used in test classes and don’t return a value.

20
Q

What should be your first choice of tool when it comes to testing?

A

Dummy data to make sure your tests are testing the right functionality

21
Q

What is a common term for dummy data?

A

CSV of data

22
Q

A Utility class can be used by…

A

multiple test classes as opposed to being called by only a single class.

23
Q

What does @testVisible do?

A

Makes private class members accessible by test classes

24
Q

@isTest(seeAllData=true)

A
  • by default is set to false,

- setting it to true gives test access to your org

25
Q

What are the 2 main uses for Test.StartTest() and Test.StopTest()?

A
  • They provide new context for the tests within specific governor limits
  • You can force Asynchronous code to behave synchronously
26
Q

What does System.Assert do?

A

Lets us evaluate the condition given and if it is true, the test passes. otherwise the test fails

27
Q

What does System.AssertEquals() do?

A

takes in two values and the first value is the expected value, so what you are expecting is going to be returned. the Second value is the returned value. if they are the same, then the test passes

28
Q

What does System.AssertNotEquals() do?

A

Works the same way as System.AssertEquals(), but if they do NOT match, the test succeeds.

29
Q

What does System.RunAs(){} do?

A

Tests the code when running it as a different user.

30
Q

What are some ways of Test Execution?

A
  • within the developer console
  • in vs code
  • Test Execution UI
  • Running tests with API
31
Q

What is our code coverage percentage?

A

Code coverage percentage represents how much of our code has been covered by unit tests. 75% in order to send to production.

32
Q

How much code coverage percentage is the minimum for triggers?

A

1%

33
Q

Testing best practices -Positive

A
  • Ensure the expected behavior occurs when the user correctly makes use of it
  • If everything is correct, we get the correct answer
34
Q

testing best practices -Negative

A

Test to ensure that if things are not correctly used, are we handling it gracefully, and the errors being returned are the correct ones

35
Q

Testing best practices -Single Action

A

Pass in a single record, does it execute correctly?

36
Q

Testing best practices - Bulk Testing

A

Pass in multiple records, 200, is there a certain point to where our code cannot handle records being passed in

37
Q

Testing best practices -Restricted User

A

Are we sharing, or not sharing, access as is appropriate