Saltar al contenido ForoHackers

Testing: start here

Pruebas
#705 · Ophuscado · · Denunciar

Testing is running software on purpose to find out whether it does what it should. A test cannot prove there are no bugs, but a good suite catches regressions, documents behaviour and lets you change code without fear. The skill is choosing a few cases that are likely to expose a failure.

Key concepts

  • Levels: unit tests for small pieces, integration tests for parts together, end-to-end tests for whole flows.
  • Test design: boundary values, equivalence classes, error paths and the cases nobody thought of.
  • Isolation: test doubles such as stubs and mocks replace slow or unreliable dependencies.
  • Determinism: a test that fails randomly teaches people to ignore failures; remove time, order and network dependence.
  • Coverage and its limits: it shows what was run, not what was checked.

Vocabulary

  • Assertion: a statement in a test that must be true, or the test fails.
  • Regression: something that worked and stopped working.
  • Fixture: the prepared state or data a test starts from.
  • Property-based testing: checking general rules against many generated inputs.

What to study, in order

  1. Write unit tests for a small function with your language's standard test framework.
  2. Practise boundary values and error cases on a function that parses input.
  3. Replace a dependency with a fake, and test a piece that talks to a database or a clock.
  4. Write a property-based test and let it find a bug in your own code.
  5. Run tests on every change automatically, and track and fix flaky ones.

Related tags

#qa #ci-cd #debugging #fuzzing

Inicia sesión o únete para responder.