Unit testing Flashcards

1
Q

What is a unit of work?

A

All the actions that take place between the invocation of an entry point up until a noticeable end result through one or more exit points. The entry point is the thing we trigger.

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

How many exit and entry points could a unit of work have?

A

one or more exit points, one entry points

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

Is the entry point something private or public?

A

Public

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

What is an exit point?

A

An exit point is an observable consequence of a unit of work that can be verified from outside the system. It’s how the system communicates or changes in a way that clients can observe.

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

What types of exit point exists?

A

Returned value
Change in state of some part f the system
Callout of third dependency such us logging

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

What are the characteristics of good test?

A

Easy to understand the intention
Easy to read and write
Automated
Consistent
Useful and actionable results
Run with a “push of a button”
Easy to trace erros

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

What does it mean that a test is consistent?

A

Each run gets the same result if u did not change anything

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

What are the characteristics of a good unit test?

A

Run quickly.
Full control of the code under test.
Do not call external dependencies such as network or database calls, runs in memory.
Isolated.
Linear when it makes sense.

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

What is the main difference between unit and integration tests?

A

Unit tests do not depend in configuring external dependencies such as databases or the filesystem.

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

Mention 3 questions of the art of unit testing checklist to ensure something is a unit test

A

Can I run and get results from a test I wrote two weeks or months or years ago?
Can any member of my team run and get results from tests I wrote two
months ago?
Can I run all the tests I’ve written in no more than a few minutes?
Can I run all the tests I’ve written at the push of a button?
Can I write a basic test in no more than a few minutes?
Do my tests pass when there are bugs in another team’s code?
Do my tests show the same results when run on different machines or environments?
Do my tests stop working if there’s no database, network, or deployment?
If I delete, move, or change one test, do other tests remain unaffected?

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

What is the consequence of not having isolation of external dependencies in a test?

A

Too much points of failure.

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

What is a regression?

A

is broken functionality—code that used to work. You
can also think of it as one or more units of work that once worked and now
don’t.

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

What three main criteria does exist to determine a good test.

A

Readability
Maintainability
Trust

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

What is a unit test?

A

A unit test is an automated piece of code that invokes the unit of work through an entry
point and then checks one of its exit points. A unit test is almost always written using a
unit testing framework. It can be written easily and runs quickly. It’s trustworthy,
readable, and maintainable. It is consistent as long as the production code we control has
not changed.

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

What does it mean the USE naming convention?

A

Unit of work under test
Scenario
Expected behavior

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

What is the assertion roulette?

A

Assertion roulette is when a single test has multiple assertions without clear indication of which one failed, making it hard to identify the exact reason for test failure.

17
Q
A