Week 6 - Testing and Build Management Flashcards
What is a unit?
Typically a single function or method
What is a good unit testing plan?
To have one test module/class per production module/class, which tests the public interface of the production class
What does the Arrange-Act-Assert Pattern divide tests into?
The arrange section
The act section
The assert section
What happens in the arrange section of the Arrange-Act-Assert Pattern?
You bring the system under test and its dependencies to a desired state
What happens in the act section of the Arrange-Act-Assert Pattern?
You can call functions/methods on the system under test, passing the prepared dependencies, and capturing the output value (if any)
What happens in the assert section of the Arrange-Act-Assert Pattern?
You verify the outcome. The outcome may be represented by the return value, the final state of the SUT and its collaborators, or the methods the SUT called on those collaborators
What does SUT stand for?
System Under Test
What are the phases of Test-Driven Development (TDD)?
Red, Green and Refactor
What does TDD stand for?
Test-Driven Development
Describe the red phase of TDD.
Write an automated test for some behaviour
Describe the green phase of TDD.
Write just enough code to pass the test
Describe the refactor phase of TDD.
Change the code so it becomes better
What is build management driven by?
Version control
What are the three benefits version control provides?
Change histories
Branching and merging
Traceability
What do change histories do?
Change histories make it possible to quickly and reliably get any version of a file
What does branching and merging do?
Makes it possible for developers to work independently, and to combine their work together, warning of any conflicts
How does version control make traceability possible?
By annotating each change with a short message describing the purpose of the change
What are the seven essential practices of continuous integration?
Do not check in on a broken build
Always run commit tests locally
Wait for commit tests to pass
Never go home on a broken build
Always be prepared to revert
Do not comment out failing tests
Take responsibility for breakages
Why should you not check in on a broken build?
There is no point checking in further changes, triggering new builds, and compounding the failure
Why should you always run commit tests locally and wait for them to pass?
So failures can be fixed right away before causing a broken build - only commit once a local build is successful
Why should you never go home on a broken build?
Because it means nobody else can work so you should check in at least an hour before the end of the working day, or first thing next morning
What should you do if a problem with a commit cannot be fixed quickly?
Revert it
What are the two common branching models?
Feature-based development and trunk-based development
Describe feature-based development.
A branch is created for each feature being developed. Merging branches is delayed until the feature is finished, possibly weeks later
Describe trunk-based development
A branch is created for each feature being developed. Merging branches is done daily, with feature flags used to hide incomplete work
What are the two common repo organisations?
Monorepo and multirepo
What is a monorepo?
One giant repo for all microservices - any check-in triggers the production of multiple microservices. Should be avoided
What is a multirepo?
One repo per microservice - any check-in triggers the production of a single microservice