Week 6 Flashcards
What is a ‘unit’?
A single function or method.
One test per module/class per production module/class, which tests the public interface of the production class.
What do opponents of unit tests say?
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).
What ratio of production code to unit tests should we have? (in lines of code)
1:3
What does the Arrange-Act-Assert pattern divide tests into?
Arrange section
Act section
Assert section
XD
What is the arrange section?
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))
What is the act section?
Call functions/methods on the system under test, passing the prepared dependencies, and capturing the output value
The assert section
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.
What are the phases of Test Driven Development?
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.
Why has version control turned into build management?
Version control used to be a safe place for source code, now it allows for collaboration, build management etc.
What is build management?
Driven by version control, providing:
1. change histories
2. branching and merging
3. traceability
What are change histories in build management?
Makes it possible to quickly and reliably get any version of a file.
What is branching and merging in build management?
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.
What is traceability in build management?
Annotating each change with a short message describing the purpose of the change.
What are the 7 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
What is ‘do not check in on a broken build’?
There is no point checking in further changes, triggering new builds, and compounding the failure on a broken build.