Testing Flashcards

1
Q

How you can invoke actions and get attributes of component in jest framework?

A

Using cmp result from $T.createComponent callback (same way as in Aura cmp.get(‘v.attributeName’) or cmp.actionName())

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

What syntax is used to check result in jest?

A

expect(condition).toBe(boolean) or similar

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

What method is used to perform action after each test executed in jest?

A

afterEach(() => {})

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

Basic structure of Jest test?

A

// test suite
describe()
// specific test case
it() or test()

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

Which methods sObject provides for inspecting errors related to records?

A

addError(), hasErrors(), getErrors()

List is used to work with errors

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

Which method is used to obtain current url of Visualforce page/controller in unit test?

A

getParameters() from PageReference

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

Which exceptions cannout be caught?

A
  1. LimitException
  2. License-related exception
  3. Exceptions that are thrown by System.assert methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Main considerations regarding @testSetup

A
  1. Any changes made to data are rolled back after each method execution.
  2. Can’t be used with SeeAllData = true
  3. Only one @testSetup can be defined for each Apex test class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to test private method?

A

Using @testVisible annotation on method declaration

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

How to make tests run asynchronously?

A
  1. Using Test tab in Developer Console (Always Run Asynch checkbox)
  2. Apex Test Execution page.

NOTE: Apex Classes can only run with All Tests option

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

How to avoid mixed DML exception when running tests?

A
  1. Use @future method to create non-setup objects (or vice versa).
  2. Use runAs block
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What can cause “You have uncommited work exception” when performing callout in est?

A

It’s occured when DML operation are performed first before callouts in the same transaction.

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

Where Code Coverage can be skipped?

A

When doing new Run in dev console or Apex Test Execution page

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

How create component in jest test?

A

$T.createComponent(componentName, params, renderOrNot)

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

How to set PageReference in test?

A

Test.setCurrentPage

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

If class annotated with SeeAllData = true and method with SeeAllData = false, will be existing data used in this method?

A

Yes. SeeAllData=true always overrides SeeAllData=false

17
Q

How to prevent UNABLE_TO_LOCK_ROW?

A

Disable Paraller Apex Testing in Apex Test Execution.

18
Q

How to run test using SOAP API?

A

RunTestsResult[] runTests(RunTestsRequest [])

19
Q

How run tests asynchronously via apex?

A

ApexTestQueueItem

ApexTestResult

20
Q

Where Store Only Aggregated Code Coverage option can be selected?

A

Apex Test Execution page

21
Q

How to instantiate controller extension in test?

A

By passing StandardController into Controller Extension costructor