ZSI / Testovanie

Testovanie

Základy softvérového inžinierstva

Sergej Chodarev (sergejx.net), Filip Gurbáľ

Ako vieme, či program funguje?

Spustíme a testujeme

Manuálne testovanie

Test Early, Test Often, Test Automatically

Tests that run with every build are much more effective than test plans that sit on a shelf.

The Pragmatic Programmer

Cena neskorého testovania

Automatické testy

Coding Ain’t Done ’Til All the Tests Run

The Pragmatic Programmer

Pojmy

Softvérové chyby a zlyhanie

Softvérová chyba - fault, error, bug - chyba v kóde, ktorá spôsobuje chybné správanie programu (správanie sa líši od očakávaného)

Softvérové zlyhanie - nie je možné dokončiť scenár (program padne, nespustí sa)

Verifikácia a validácia

Verifikácia – overenie správnosti produktu vzhľadom k formulovaným požiadavkám (Vytvárame produkt správne?)

Validácia – overenie správnosti produktu vzhľadom k potrebám zákazníka (Vytvárame správny produkt?)

Testovací prípad a testovacia sada

Test case - testovací prípad (konkrétny test)

Test suite - sada testov

Test scenario - testovací scenár sa využíva hlavne pri manuálnom testovaní

Metódy testovania

Skrinky

Black box testing - testovanie čiernej skrinky

White (clear) box testing - testovanie bielej skrinky

Grey box testing - kombinácia testovania čiernej a bielej skrinky

Testovanie na základe špecifikácie alebo kódu

Specification-based testing - testovanie len na základe špecifikácie

Code-based testing - testovanie na základe implementácie

Testing pyramid

Jednotkové testy

Čo je jednotka?

Jednotkové testy

Čo testovať?

Testing Is Not About Finding Bugs

A test is a perspective into your code, and gives you feedback about its design, API, and coupling.

The Pragmatic Programmer

Mocking

Štýly testovania

Štruktúra testu

3A:

Testovacie knižnice:

Integračné testy

End-to-end testy

Akceptačné testy

Pokrytie kódu testmi

Kedy písať testy?

Keď máme čo testovať

Alebo ešte skôr

Test-driven development

Test-driven development (TDD)

  1. Napísať test (alebo jeho časť) – červená
  2. Napísať kód, aby testy prešli – zelená
  3. Zlepšiť kód – refactoring

A Test Is the First User of Your Code

Use its feedback to guide what you do.

The Pragmatic Programmer

Design to Test

Start thinking about testing before you write a line of code.

The Pragmatic Programmer

Test Your Software, or Your Users Will

Test ruthlessly. Don’t make your users find bugs for you.

The Pragmatic Programmer

Never Expect Your Software to be Perfect

Program testing can be used to show the presence of bugs, but never to show their absence!”