sunjay / turtle

Create Animated Drawings in Rust
http://turtle.rs
Mozilla Public License 2.0
562 stars 53 forks source link

Drawing Tests #21

Open sunjay opened 7 years ago

sunjay commented 7 years ago

It's hard to have functional testing based on the graphics drawn on the screen because comparing images is hard to do automatically. What if instead we added a special test drawing command that outputted a serialized form of the drawings in the drawings stored in the renderer process. We could perform some rounding to account for floating point error and then compare the drawings produced to an expected output.

More concretely, we would add a test to the tests directory called example-checker.rs or something. It would run each example in the examples directory and check its output against an expected output. If there is a mismatch or we don't have an expected output file yet, the test fails and we output the serialized drawings into a target/example-checker directory for diffing.

This lets us check all examples for their output.

An additional, optional feature that would be useful would be way to get the turtle to quickly draw up the drawing in the serialized output so we could see the difference.

To look into: event simulation support (i.e. being able to fake events for examples that use events)