Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing to avoid doubting

Benjamin Cavy
July 13, 2023
17

Testing to avoid doubting

Benjamin Cavy

July 13, 2023
Tweet

Transcript

  1. SLIDESMANIA.COM SLIDESMANIA.COM My dream test 🎯 fails only when it

    should 🧪 is reproductible ⏩ runs quickly 💡is easy to understand
  2. SLIDESMANIA.COM SLIDESMANIA.COM Test pyramid Units Integration E2E 🧪 🧪 🧪

    ⏩ ⏩ ⏩ 🧪 ⏩ 🧪 🧪 🧪 ⏩ ⏩ Not reproductible
  3. SLIDESMANIA.COM SLIDESMANIA.COM Unit tests shortcomings 🪢 Tighten coupling with code

    structure ⛓ Make refactoring harder 🧩 Testing pieces of code, not application features 😨 I got little faith in unit tests
  4. SLIDESMANIA.COM SLIDESMANIA.COM Integration tests : my guidelines 🧑💻 Focus on

    features / user journey 📦 Test in black box mode 🍾 Mock only what’s strictly necessary
  5. SLIDESMANIA.COM SLIDESMANIA.COM Test containers Containers orchestrated by your tests 🪩

    Java, node, python, go, rust, … 🪞 « ISO prod » technical environnement
  6. SLIDESMANIA.COM SLIDESMANIA.COM Wiremock Stubs for HTTP cakks 🍾 Fine grain

    stubbing ⚙ Standalone server ✅ Call check Alternatives oMock-server (node) oMock Service Worker (frontend)
  7. SLIDESMANIA.COM SLIDESMANIA.COM Cypress Fast, easy and reliable tes:ng for anything

    that runs in a browser. 🎇 An UI that allows to clearly visualise all test steps 🧰 naviga9on, stubbing, and async asser9on features 🔎 4 supported browsers
  8. SLIDESMANIA.COM SLIDESMANIA.COM Pros 💥 Failure : behaviour has changed 🔧

    Refactoring resilient ✅ Test the whole stack (SQL queries, …) 💡 Allow to imagine features from user perspective
  9. SLIDESMANIA.COM SLIDESMANIA.COM Pain points 🛠 Stubbs are hard to maintain

    🐌 Things can get slow 🤯 Test code may become hard to read
  10. SLIDESMANIA.COM Total decoupling Reboot / complete reset between tests It’s

    slow !!! 2 main causes 🚚 Technical elements instantation 📑 Functionnal setup String coupling Context is kept between tests ⚠ Dependant of execution order Coupling « happy medium » Programmatic cleaning Common setup for a whole test suite
  11. SLIDESMANIA.COM SLIDESMANIA.COM My tests are too complicated ! 🔧 Extract

    « test primiBves » 🛠 FuncBonnal builders 🚆Focus on one target in each test