Ever get the feeling that your unit tests aren't really unit-ish? That's because proper unit tests are hard - you start off with something good, then you start making all sorts of compromises which eventually lead you to an unmaintainable mess. A lot of the time we are writing tests by pure intuition so I'd like to discuss a repeatable methodology for writing automated tests, while focusing on proper unit tests:
- Approaching tests (writing maintainable example groups)
- Identifying tests subjects (and understanding what you actually want to accomplish in the test)
- Categorising tests (state tests vs. interaction tests)
- Isolating test subjects (understanding stubs vs. mocks and exactly when you should use them)
- Structuring tests (arrange-act-assert, given-when-then, test spies)
In this talk we'll go through different code examples that demonstrate test boundaries, scoping, structure and several other techniques that will help you keep your unit tests from degrading into a slop of integration tests.
אין תגובות:
הוסף רשומת תגובה