UncleBobsThreeTDDRules
Can someone tell me the difference between 1 and 3? it's not very clear to me.
To me 1 and 3 can be combined or are these rules suggesting order as well?
First of all: I'd take these rules with a grain of salt.
That said, rule one and rule three have a slightly different notion:
Rule 1: You should not write any code without having a failing test.
Rule 3: You should not implement a complete algorithm (even though it would make the test pass) but only the simplest possible (some might say naive) solution to make the test pass.
An example:
Given you want a method that takes a number and returns the very same number. Say you have the following test:
public void Entering1Returns1() {
assert.That(calculate(1) == 1);
}
This implementation would comply to both rules:
public void calculate(int input) {
return 1;
}
This one would violate rule 3 (strictly speaking) because it does more than needed:
public void calculate(int input) {
return input;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With