Просмотр исходного кода

two-fer: update hint file with TDD notes

Stuart Kent 9 лет назад
Родитель
Сommit
d9b77b28b8
1 измененных файлов: 38 добавлений и 3 удалений
  1. 38
    3
      exercises/two-fer/HINTS.md

+ 38
- 3
exercises/two-fer/HINTS.md Просмотреть файл

@@ -1,3 +1,38 @@
1
-To help you focus on one test at a time, [@Ignore](http://junit.sourceforge.net/javadoc/org/junit/Ignore.html)
2
-annotations have been added to every test but the first one. Any test with an `@Ignore` annotation will be skipped
3
-when you run the tests.
1
+Most Java exercises include multiple test cases. These cases are structured to
2
+support a useful process known as
3
+[test-driven development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development).
4
+TDD involves repeating a structured cycle that helps programmers build complex
5
+functionality piece by piece rather than all at once. That cycle can be
6
+described as follows:
7
+
8
+1. Add a test that describes one piece of desired functionality your code is
9
+currently missing.
10
+2. Run the tests to verify that this newly-added test fails.
11
+3. Update your existing code until:
12
+    - All the old tests continue to pass;
13
+    - The new test also passes.
14
+4. [Clean up](https://en.wikipedia.org/wiki/Code_refactoring) your code, making
15
+sure that all tests continue to pass. This typically involves renaming
16
+variables, removing duplicated chunks of logic, removing leftover logging, etc.
17
+5. Return to step 1 until all desired functionality has been built!
18
+
19
+The test files in this track contain _all_ the tests your solution should pass
20
+to be considered valid. That doesn't immediately seem to be compatible with the
21
+cycle described above, in which tests are written one by one. However, the
22
+tool that we use to write our tests, [JUnit](http://junit.org), provides an
23
+[@Ignore](http://junit.sourceforge.net/javadoc/org/junit/Ignore.html)
24
+[annotation](https://docs.oracle.com/javase/tutorial/java/annotations/) that
25
+can be used to temporarily skip an already-written test. Using this annotation,
26
+we make sure that the test files we deliver to you satisfy the following rules:
27
+
28
+- The first test in any test file is _not_ skipped by default.
29
+- All but the first test in any test file _are_ skipped by default.
30
+
31
+This allows you to simulate the TDD cycle by following these slightly-modified
32
+steps:
33
+
34
+1. Run the tests to verify that _at most one_ test currently fails.
35
+2. Update your existing code until all the non-skipped tests pass.
36
+3. Clean up your code, making sure that all non-skipped tests continue to pass.
37
+4. Remove the topmost `@Ignore` annotation in the test file.
38
+5. Return to step 1 until no tests are skipped and all tests pass!