🏁
Best Practices
  • Introduction
  • The Big Picture
    • Principles
      • Software engineers solve business problems
      • Programming is a social activity
      • Attention is the most precious resource in a project
      • Simplicity is the best ally in the long run
      • The only problem to solve is the one we have today
    • Architecture
      • Domain
      • Services
      • Persistence
      • HTTP
      • UI
    • Naming
  • Constraints
    • TypeScript
    • Monorepo
    • Monolith
    • Versioning
  • Source code
    • Declarative programming
    • The README
    • Modules
    • Folder structure
    • Code formatting
    • Code comments
  • The Outside World
    • Runtime configuration
    • Logging
  • Testing
    • The purpose of testing
      • End-to-end tests
      • Integration tests
      • Unit tests
  • Tools
    • Git
  • Resources
    • Resources
Powered by GitBook
On this page

Was this helpful?

  1. Testing

The purpose of testing

PreviousLoggingNextEnd-to-end tests

Last updated 5 years ago

Was this helpful?

The purpose of testing is to ensure the product works according to its business purposes. It must work even after adding or removing functionality or refactoring the codebase.

Testing is crucial. It is also a convoluted topic and can quickly turn into a counterproductive time sink.

Keeping the goal of testing and the in mind, I suggest the following pragmatic approach.

Implement three types of automated tests, in order of importance:

  • Complete end-to-end (browser/app) tests that verify the user-facing features

  • Integration tests that verify the machine facing APIs

  • A few developer tests (aka unit tests)

Sacrifice the lower priority tests if your resources are limited.

Treat tests as proper code, do not take shortcuts: , type-safe, lint - stick to the good practices.

Tests will usually require similar data across multiple test instances and types. Maintain a single source for the different types of test data, so that you can update it in one go. For anything non-trivial a type-safe factory is suggested (for example ).

core principles
be declarative
factory-ts