TDD'nin Üç Yasası
Üretim ve test kodunu tam olarak ne zaman yazabileceğinizi belirleyen Robert Martin'in TDD'nin üç yasasını özümseyin.
TDD'nin Üç Yasası, CoddyKit'te ücretsiz bir Testing Mastery: JUnit, Mockito & Integration Tests dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Testing Mastery: JUnit, Mockito & Integration Tests öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Testing Mastery: JUnit, Mockito & Integration Tests kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Discipline Behind the Cycle
The red-green-refactor cycle becomes precise through three short rules known as the Three Laws of TDD, formulated by Robert C. Martin. They constrain exactly when you write code.
The First Law
Law 1: You may not write production code until you have written a failing unit test.
No code is added speculatively. Every line exists to satisfy a test.
The Second Law
Law 2: You may not write more of a unit test than is sufficient to fail. A compilation failure counts as failing.
The Third Law
Law 3: You may not write more production code than is sufficient to pass the currently failing test.
A Tiny Failing Test
Following Law 2, write only enough test to fail. Here the class does not even exist yet, so it fails to compile.
@Test
void addsTwoNumbers() {
assertEquals(5, new Calc().add(2, 3));
}Just Enough Production Code
By Law 3 you write the minimum to pass, even if it looks naive at first.
class Calc {
int add(int a, int b) { return a + b; }
}Tight Loop
The three laws lock you into a loop measured in seconds, not minutes: write a bit of failing test, write a bit of code, repeat.
Why So Strict?
The strictness guarantees every line of production code is covered by a test and keeps you from over-engineering features no test demands.
Avoiding Speculative Design
Because you only write code that a test requires, you naturally avoid YAGNI violations (You Aren't Gonna Need It) and dead code.
Practicing the Laws
The laws feel restrictive at first. With practice the loop becomes muscle memory, producing comprehensive test coverage almost as a side effect.
Relationship to Red-Green-Refactor
The laws drive the red and green phases; refactoring still happens once tests pass, with the safety net the laws built.
Quick Check
According to the first law, when may you write production code?
Recap
You learned the disciplined core of TDD:
- Law 1: no production code without a failing test
- Law 2: write only enough test to fail
- Law 3: write only enough code to pass
- The laws create a tight loop and full coverage
Sıkça Sorulan Sorular
“TDD'nin Üç Yasası” dersi ücretsiz mi?
Evet — “TDD'nin Üç Yasası” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Testing Mastery: JUnit, Mockito & Integration Tests kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Testing Mastery: JUnit, Mockito & Integration Tests kursu toplamda 4 dersten oluşur.
“TDD'nin Üç Yasası” dersinde ne öğreneceğim?
Üretim ve test kodunu tam olarak ne zaman yazabileceğinizi belirleyen Robert Martin'in TDD'nin üç yasasını özümseyin. Testing Mastery: JUnit, Mockito & Integration Tests ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Testing Mastery: JUnit, Mockito & Integration Tests öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Testing Mastery: JUnit, Mockito & Integration Tests, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“TDD'nin Üç Yasası” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Testing Mastery: JUnit, Mockito & Integration Tests dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Testing Mastery: JUnit, Mockito & Integration Tests dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.