Skip to content

Commit a0a9670

Browse files
Tests (#558)
* Add tooling testing * Add more
1 parent 4578628 commit a0a9670

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

building/tooling/best-practices.md

+22
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,28 @@ ENTRYPOINT [ "sh", "/opt/test-runner/bin/run.sh" ]
225225
The [C# test runner's Dockerfile](https://github.com/exercism/csharp-test-runner/blob/b54122ef76cbf86eff0691daa33c8e50bc83979f/Dockerfile) does something similar, only in this case the build stage can use an existing Docker image that has pre-installed the additional packages required to install libraries.
226226
```
227227

228+
## Testing
229+
230+
### Use integration tests
231+
232+
Unit tests can be very useful, but we recommend focusing on writing [integration tests](https://en.wikipedia.org/wiki/Integration_testing).
233+
Their main benefit is that they better test how tooling runs in production, and thus help increase confidence in your tooling's implementation.
234+
235+
#### Use Docker
236+
237+
To best mimic the production environment, the integration tests should run the tooling _like the production environment_.
238+
This means building the Docker image and then running the built image on a solution to verify its output.
239+
240+
#### Use golden tests
241+
242+
Integration tests should be defined as [golden tests](https://ro-che.info/articles/2017-12-04-golden-tests), which are tests where the expected output is stored in a file.
243+
This is perfect for track-tooling integration tests, as the output of tooling are also files.
244+
245+
##### Example: test runner
246+
247+
When running the test runner on a solution, its output is a `results.json` file.
248+
We can then compare this file against a "known good" (i.e. "expected") output file (named `expected_results.json`) to check if the test runner works as intended.
249+
228250
## Safety
229251

230252
Safety is a main reason why we're using Docker containers to run our tooling.

0 commit comments

Comments
 (0)