Skip to content

Commit 278d119

Browse files
committed
Merge branch 'issue-38-tdd'
Fixes #38
2 parents a1a18eb + f32141a commit 278d119

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

rules/0120-Tests.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,31 @@ overall quality of the approved katas. Also, as long as [#123] stands, one
1010
cannot change the tests in approved katas with more than 500 solutions.
1111

1212
[#123]: https://github.com/Codewars/codewars.com/issues/123
13+
14+
15+
## Consider writing your tests first
1316

17+
Before we actually dive into the many tips one can follow on Codewars, you
18+
should get familiar with the test driven development (TDD) cycle. It's not
19+
required to follow it in order to write katas for Codewars, but _recommended_.
20+
21+
So what is the cycle? Essentially, it's the following:
22+
23+
1. Add a test
24+
2. Run tests and verify that the new one fails
25+
3. Adjust your solution
26+
4. Run tests and verify that the new solution passes all tests
27+
5. Refactor your solution (optional)
28+
29+
That's it. Note that the important part is the very first step: you write the
30+
tests first. "Why?", you're probably asking. "I know my solution already!"
31+
Well, are you sure about that? Some katas have long standing issues since the
32+
original author didn't check a few edge cases.
33+
34+
However, since Codewars isn't running on your own machine, you should adjust
35+
the cycle a little bit and add more than a single test. The cycle works best
36+
with fast iterations, and the remote nature of Codewars makes this a little bit
37+
hard. Still, writing at least part of your tests first is __very__ recommended.
1438

1539
## Make your test descriptive
1640

@@ -245,7 +269,7 @@ def add_three_reference(a,b,c):
245269
return a + (b + c)
246270

247271
print(add_three_reference(1e-12,1e-12,1) == add_three(1e-12,1e-12,1))
248-
# False
272+
# False
249273
```
250274

251275
### Relative error testing

0 commit comments

Comments
 (0)