Saltar al contenido ForoHackers

Testing: start here

Pruebas
#3211 · · Citar · 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

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder