Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put exercise generation under test (#426)
* Put exercise generation under test This change alters `ExercismGenerator` just enough to allow side effect free tests. Having the class under test enables future refactoring. Three dependencies made this class difficult to test: - `PipeableOSProcess` executed commands outside of the Pharo VM - `ExTonelWriter` wrote files to the OS filesystem - `ExercismExercise` would access a variable number of exercises depending on how many were implemented To get this class under test the above dependencies have been placed in lazy assigned instance variables. This allows tests to assign mocks to the generator instance. There are two mock OS processes, one that always succeeds, and one that always fails. Neither executes any function outside the VM. A `ExTonelWriter` writes exercises to an in memory file system that lasts only for the test. A mock exercism exercise class returns only a single exercise. This speeds up the test and makes it more consistent as it won't change when more exercises are implemented. ## Test Issues with Line Endings When run in CI (Ubuntu 16.04) one of the tests failed, but the same test passed on my personal computer (MacOS). I suspect that even though the tests use an in memory file system, OS specific line-feed and carriage-return characters will be used. This causes enough of a difference between the expected result and the actual result that the outcome will be a failed test. Each test that works with an in memory file system will normalize the line endings of the expected result and the actual result to the same character. This should eliminate this kind of environment specific failure in tests. The test design closely follows that of `TonelWriterTest` which also uses an in memory file system.
- Loading branch information