- Define test setup, such as CF and BOSH APIs, or mock service adapters as close to the test as possible
- Don't modify a generic test setup for each context, create a new one
- Consider fluent builders to make this clear, without requiring excessive code
- Strongly consider any requirement to set up in BeforeSuite
- Avoids mutation leaks by avoiding shared variables between tests
- Locally defined setup for each test removes the need to run JustBeforeEach after some local BeforeEach
- The "Act" from Arrange, Act, Assert should happen close to, or in, the
It()
not in a global JustBeforeEach
- When testing long running actions, combine related assertions in a single
It()
, BeforeEach is no longer required - Cost of repeatedly running long running actions to assert on related responses is high
- Use the most appropriate matcher for the situation
- For example,
SatisfyAll()
will match a number of related assertions - Spend time when writing tests to select the most appropriate tool
- Use the most appropriate Ginkgo tool
- Consider if multiple contexts testing a similar action could be a table test
- Avoid implementation details in Context and It descriptions
- Use ‘responds with...’ to describe HTTP responses, instead of ‘returns...’
- The broker package is large and growing, what can be extracted?
- Split long files when they grow unwieldy.
- Avoid coupling to another package by using its error types. Create an interface that describes the error's behaviour and assert the interface. Dave Cheney gives an example of how to avoid such 'Sentinel' errors.
Not bad. Can we publish these?