TDD (Test-driven development)
Në shqip: Zhvillim i drejtuar nga testet
ShpjegimiSQ
TDD-ja është një mënyrë pune ku testin e shkruan para kodit: fillimisht testi dështon (i kuq), pastaj shkruan kodin minimal që ta kalojë (i gjelbër), dhe në fund e rregullon kodin (refactor).
EnglishEN
TDD is a way of working where you write the test before the code: first the test fails (red), then you write the minimum code to pass it (green), and finally you tidy up the code (refactor).
Si ta mendosh
Si ta shkruash fillimisht pyetjen e provimit dhe përgjigjen e saktë, e pastaj të mësosh derisa ta japësh atë përgjigje.
Lexoje në anglisht
Like writing the exam question and its correct answer first, then studying until you can give that answer.
Shembull kodipython
def test_mblidh():
assert mblidh(2, 3) == 5 # 1. shkruaj testin (dështon)
def mblidh(a, b):
return a + b # 2. shkruaj kodin që e kalon