|
| 1 | +At the most basic level, Exercism is all about the tests. They drive the user's implementation forward and tell them when the exercise is complete. |
| 2 | + |
| 3 | +The utmost care and attention should be used when adding or making changes to the tests for an exercise. When implementing an exercise test suite, we want to provide a good user experience for the people writing a solution to the exercise. People should not be confused or overwhelmed. |
| 4 | + |
| 5 | +We simulate Test-Driven Development (TDD) by implementing the tests in order of increasing complexity. We try to ensure that each test either |
| 6 | + |
| 7 | +- helps triangulate a solution to be more generic, or |
| 8 | +- requires new functionality incrementally. |
| 9 | + |
| 10 | +The characteristics of a good individual test are: |
| 11 | + |
| 12 | +- a clear name or description that reveals the intent of the test |
| 13 | +- a minimal amount of setup |
| 14 | + - Temporary variables should be avoided unless they add to the test's clarity. |
| 15 | + - Well named test helpers can be employed to encapsulate shared setup between tests. |
| 16 | + - Test helpers should be extremely simple, and branching logic inside a helper is to be avoided. |
| 17 | +- a manageable increase in complexity from the previous passing test |
| 18 | +- introduces a single new requirement |
| 19 | +- a minimal number of expectations required to specify the change (one expectation is preferred) |
| 20 | +- a readable and understandable failure message |
| 21 | +- adherence to the testing idioms of the language and testing framework of the track |
| 22 | +- does not duplicate the expectations of another test |
| 23 | + |
| 24 | +The test suite of an exercise should be guided by the common specifications laid out by the `canonical-data.json` file of each exercise in [x-common](https://github.com/exercism/x-common) if it is available. The specifications there provide good defaults for: |
| 25 | + |
| 26 | +- the order of the tests |
| 27 | +- the descriptions of the tests |
| 28 | +- the inputs and expected outputs of each test |
| 29 | + |
| 30 | +Feel free to implement a test generator for your track if you feel it would aid in creating test suites from `canonical-data.json`. |
| 31 | + |
| 32 | +The specifications in `canonical-data.json` are the strongly recommended defaults, but if you have a good reason (language idioms, etc) then don't hesitate to deviate from them. |
| 33 | + |
| 34 | +If there is no `canonical-data.json` file for the exercise then we recommend using http://x.exercism.io/problems/hello-world (replace hello-world with the exercise in question) or http://exercism.io/languages/vimscript/todo (replace vimscript with your track) to find other implementing tracks. |
0 commit comments