General info
Theory to practice ratio: 95% practice
Duration: 3 days
Goal
This training is design to make writing tests easier by:
- showing how good practices in writing code translate to easy to write tests
- learning how to refactor bad code to easily testable code.
- making sure attendees know the testing tools that they use daily
- organizing when to use which approach in testing different scenarios
- passing good practices that minimize test maintenance overhead
- learning when to remove tests
Program
- Introduction
- Testing
- How to name tests
- How to write assertions
- Test organization
- DRY in tests
- Patterns and anti-patterns in tests.
- Inheritance vs. Composition
- Integration tests
- Data Driven testing
- How to set up and organize
- How to collect sample data from production and test environments
- Combinatorial testing
- Managing the number of test cases
- Evaluating the benefits and drawbacks
- Time saving features of testing frameworks (NUnit/Fluent Assertions)
- Mocking
- Understanding how mocking works.
- When to mock and when not to.
- Mock verification.
- Time saver features of mocking frameworks (Moq/NSubstitute)
- Good code leads to easy tests On a very simple program, attendees experience how good code allows moving from a complex 50 test to a 5 line one.
- SOLID as guidance on how to write testable code We start from a sample “not too bad” application, and by applying SOLID principles and refactoring the code, we can write more straightforward tests that have a higher coverage.
- Design patterns as recipes to testable code
- Factory and Abstract Factory design pattern - how to write less but more meaningful tests
- Builder design pattern - its usage in testing
- Strategy design pattern - separating object responsibilities leads to easy to test classes
- State Machine design pattern - rethinking design habits with OOP principles leads to readable and trivial to test code
- Rules design pattern - moving from nested ifs to a clean and testable code
- Singleton design pattern - the proper usage of one of the most common design patterns
- [Optional] Testing Angular
- Unit tests
- Service testing
- Integration tests
- Component tests
- Component integration tests
- UI test
- Router tests
Materials
After the training all attendees get a before and after zip package with all excercises done during the workshop.