Chimp: Fixtures-hell - how to void it? Whats best practise?

Hi there,

I am proud to announce that - with my chimp acceptance tests - I have now officially arrived in fixtures-hell!

Fixtures-Hell is when you have shit-loads-of hard-coded data lying in JSON-files (totally independend from your factories that created them) and you now have to manually manage their conistency (p.e. _id-references).

Scenario

  1. My app has multiple collections/use-cases all hanging together via _id-fields - they even reference to Meteor.users._id fields… plus I am using mizzoa:partitioner, have several tenants that I also need to test (which does not make it easier)
  2. I have lots of tests that need hard-code data to test against
  3. I have some tests that need mass-data (for example 2000 docs to test pagination thru a table via aldeed:tabular)

Right now my solution is an “put-it-all-into-json”-files approach, which is probably responsible for me being in “Fixtures Hell”. Basically I create random-data via factories and then put them into json-files. Within my tests I then load data from the json-files back into the database. this kind of smells (puhh)

The bad thing about this approach is that I have to manually manage all those _id references - possible leading to inconsistent/corrupt data Damn this sucks!

What is best-practise for this scenario? Do you have any tips you can share for a medium-sized project?

Thanks a lot for your tips guys!

3 Likes

The way I avoid it on my enterprise projects (not necessarily chimp) is to define an API based on how a person would typically use it. This was done using Selenium to control the UI and JUnits to connect to the database make assertions on the data.

A side effect of this was most of the effort that was put into writing these tests were leveraged when the data migration from legacy systems became part of the deliverable. Since we had most of the logic done into reusable API chunks that were just hard coded for testing, we just shifted them to the application side, turn on auto-commit and changed it to take in an Excel sheet for input.

The one thing we didn’t port over was the selenium side though because we want it to run in headless mode.

1 Like