Unit Testing & Testability Flashcards

1
Q

What is unit testing?

A

Ensuring the functionality of each component works in isolation

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

Unit testing is not about how well things ________ with each other

A

interact

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

Describe the automated testing pyramid

A

It’s a 3 level pyramid. The bottom row is unit testing, the middle row is API/integration/component testing, and the top row is System & UI testing

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

In the automated testing pyramid, lower levels are __________ and quick to test, while upper levels are __________ and slower to test

A

isolated, integrated

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

In practice, there is a debate between how _______ a unit test should be and ____ and _______ testing methodologies

A

isolated, big, small

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

Another view of unit tests is that they specify the expected ________ of individual components

A

behavior

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

What is test driven development?

A

Building unit tests first, then using them to guide development

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

In practice, ______ _________ development has fallen out of favour due to the nature of agile development methods, which includes ever changing requirements

A

test driven

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

What are 3 guiding principles on writing unit tests?

A
  • Focus on one component in isolation
  • Be simple to set up and run
  • Be easy to understand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In GoogleTest, what is the difference between ASSERT and EXPECT oracles?

A

ASSERT oracles terminate the program when the fail, which EXPECT oracles allow the program to continue running

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

If you have many tests the require a common set up and tear down routine, consider grouping them in a ______. What do they do?

A

fixture. Fixtures enable using the same configuration for multiple tests

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

What are the 3 steps usually occurring in a unit test? This is also known as AAA, which stands for what?

A
  1. Set up a scenario
  2. Run the scenario
  3. Check the outcome
    AAA stands for Arrange, Act, and Assert
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Two test cases modifying the same DB violates _______ because why?

A

isolation. The order of the test can affect the results

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

__________ __________ allows the use of mocks and stubs as necessary

A

Dependency injections

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

When checking pre and post conditions, you check the ________ state as well as the final state

A

initial

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

What are you checking when using a relative effects pattern of unit testing?

A

The final state relative to the initial state

17
Q

You can use ______ to check interactions and behaviors

A

mocks

18
Q

What are some factors that make writing tests hard? (5)

A
  • Connections between classes
  • Singletons
  • Nondeterminism
  • Static Binding
  • Mixing construction and application logic
19
Q

What can mocks and stubs offer us in relation to the components we are testing?

A

They can offer us isolation

20
Q

Using dependency injections with mocks/stubs can lead to a lot of ___________ code

A

boilerplate code

21
Q

To mitigate boilerplate code when testing, we can use ________ ________

A

testing frameworks

22
Q

To remove boilerplate code from mocking, what frameworks exist?

A

GoogleMock, Mockito, etc

23
Q

To remove boilerplate code from dependency injections, what frameworks exist?

A

Google Guice, Pico Container

24
Q

_____ are more useful when your testing your own component

A

mocks

25
Q

_____ are more useful when testing external components outside of your control

A

stub

26
Q

Testing small components raises confidence in the system by raising confidence in it’s ________

A

constituents