Week 6 Flashcards

1
Q

What is a ‘unit’?

A

A single function or method.
One test per module/class per production module/class, which tests the public interface of the production class.

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

What do opponents of unit tests say?

A

They complain about having to test all methods in order to achieve high test coverage.
Test only public interfaces, do not test trivial code.
(getters/setters).

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

What ratio of production code to unit tests should we have? (in lines of code)

A

1:3

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

What does the Arrange-Act-Assert pattern divide tests into?

A

Arrange section
Act section
Assert section
XD

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

What is the arrange section?

A

You bring the system under test and its dependencies to a desired state (e.g. fake a database with 3 records in it (mock or stub))

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

What is the act section?

A

Call functions/methods on the system under test, passing the prepared dependencies, and capturing the output value

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

The assert section

A

Verify the outcome. May be represented by the return value, final state of the SUT and its collaborators, or the methods the SUT called on those collaborators.

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

What are the phases of Test Driven Development?

A

Red- write an automated test for some behaviour
Green - write just enough code to pass the test
Refactor - change the code so that it becomes better.

Can lead to poor structure and hacky code.

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

Why has version control turned into build management?

A

Version control used to be a safe place for source code, now it allows for collaboration, build management etc.

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

What is build management?

A

Driven by version control, providing:
1. change histories
2. branching and merging
3. traceability

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

What are change histories in build management?

A

Makes it possible to quickly and reliably get any version of a file.

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

What is branching and merging in build management?

A

Makes it possible for developers to work independently, and combine their work together, warning of any conflicts. You work on a branch off of the main trunk, and merge them back later.

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

What is traceability in build management?

A

Annotating each change with a short message describing the purpose of the change.

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

What are the 7 essential practices of continuous integration?

A
  1. do not check in on a broken build
  2. always run commit tests locally
  3. wait for commit tests to pass
  4. never go home on a broken build
  5. always be prepared to revert
  6. do not comment out failing tests
  7. take responsibility for breakages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is ‘do not check in on a broken build’?

A

There is no point checking in further changes, triggering new builds, and compounding the failure on a broken build.

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

What is ‘always run commit tests locally’?

A

Only commit once a local build is successful.

17
Q

What is ‘wait for commit tests to pass’?

A

Check in at least an hour before the end of the working day, or first thing next morning. Don’t go home on a broken build.

18
Q

What is ‘always be prepared to revert’?

A

If a problem with a commit cannot be fixed quickly, revert it.

19
Q

What is ‘do not comment out failing tests’?

A

This is the start of a slippery slope to low quality. Do not comment out failing tests. Fix them.

20
Q

What is ‘take responsibility for breakages’?

A

If you break it, you fix it, now.

21
Q

What are build indicators?

A

Green indicates when a build is good, red indicates when a build is bad. They are hooked up to a build management.

22
Q

What are the two branching models?

A

Feature based development
Trunk based development

23
Q

What is feature based development?

A

A branch is made for each feature being developed
Merging branches is delayed until the feature is finished, possibly weeks later
Can cause inconsistencies over long periods of time, resolve conflicts.

24
Q

What is trunk based development?

A

In trunk-based development, a branch is again created for each feature being developed.
Merging branches is done daily, with feature flags used to hide incomplete work.

25
Q

What are the two repo organisation types?

A

Monorepo
Multirepo

26
Q

What is monorepo?

A

One common repo organisation, monorepo, has one giant repo for all microservices - any check in triggers the production of multiple microservices
Avoid this in the early stages of a project.