Testing for developers

Reading time ~1 minute

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

  1. Introduction
  2. Testing
    1. How to name tests
    2. How to write assertions
    3. Test organization
    4. DRY in tests
    5. Patterns and anti-patterns in tests.
      1. Inheritance vs. Composition
      2. Integration tests
    6. Data Driven testing
      1. How to set up and organize
      2. How to collect sample data from production and test environments
      3. Combinatorial testing
      4. Managing the number of test cases
      5. Evaluating the benefits and drawbacks
    7. Time saving features of testing frameworks (NUnit/Fluent Assertions)
  3. Mocking
    1. Understanding how mocking works.
    2. When to mock and when not to.
    3. Mock verification.
    4. Time saver features of mocking frameworks (Moq/NSubstitute)
  4. 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.
  5. 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.
  6. Design patterns as recipes to testable code
    1. Factory and Abstract Factory design pattern - how to write less but more meaningful tests
    2. Builder design pattern - its usage in testing
    3. Strategy design pattern - separating object responsibilities leads to easy to test classes
    4. State Machine design pattern - rethinking design habits with OOP principles leads to readable and trivial to test code
    5. Rules design pattern - moving from nested ifs to a clean and testable code
    6. Singleton design pattern - the proper usage of one of the most common design patterns
  7. [Optional] Testing Angular
    1. Unit tests
    2. Service testing
    3. Integration tests
    4. Component tests
    5. Component integration tests
    6. UI test
    7. Router tests

Materials

After the training all attendees get a before and after zip package with all excercises done during the workshop.