Adding acceptance tests to the Machine Shop Simulator - Athear/Machine-shop-simulator GitHub Wiki

The simulator came with essentially no tests, and I've learned the hard way that it's just Not A Good Idea to refactor without good test support, so I wanted to add at least some acceptance tests to the project before we start. These were added in this commit.

Because the Machine Shop code was all built about reading from standard input and writing to standard output, the bulk of these acceptance tests take the form of a test input file such as OneMachineFiveTasks.input (to read from) and an expected output file such as OneMachineFiveTasks.output (to compare against the actual output).

Some of these tests were generated by hand, but many of them were randomly generated to provide improved test coverage. The random tests were generated using the GenTestCases.rb Ruby script.

The class applications.FileIoTests then runs the simulator on all these input files and asserts that the output is the same as the expected output.

As an aside, I wrote these acceptance tests several years ago, and did the whole thing in Java. If I were doing this from scratch now I would seriously consider using a tool like Cucumber or Aruba to generate these tests instead.