Growstuff / growstuff

Open data project for small-scale food growers
http://growstuff.org/
GNU Affero General Public License v3.0
424 stars 212 forks source link

Add property-based testing #911

Open pozorvlak opened 8 years ago

pozorvlak commented 8 years ago

In other projects, I've found property-based testing to be a good way of catching bugs I'd never have thought to unit-test for. A quick Google turns up this property-based testing library for Ruby, which while not state-of-the-art looks good enough to get started with. I think this would be a relatively cheap way of increasing our coverage, finding bugs and making our code more robust.

Property-based tests usually use randomness, so we'd need to think about either (a) not running them in CI, or (b) somehow fixing the random seed so our builds don't become non-deterministic.

pozorvlak commented 8 years ago

I had a thought about this: a good place to start could be... wait for it... controller tests! Throw random input data at our routes, and assert that we never see a 5xx error. This should avoid most of the brittleness problems of hand-crafted controller tests.