JMVC 3.2.4
Hello all,
TL;DR - Should tests be shared between app code and tests?
I'm currently test-driving with QUnit alongside legacy code but I'm struggling with existing fixtures being used to represent static production data (using $.ajax.fixture() to serve data). This is my proposed solution. Is this the JMVC approach?
- Replace all instances of $.ajax.fixture() in live code with a resolved $.Deferred() (static data inside)
- Fixtures are then all defined in fixtures.js and are shared between app and test code.
- $.fixture.on = false in app code when code is live. $fixture.on = true in app code when developing and for tests.
I haven't seen any examples of JMVC tests and fixtures fully levered so I'm guessing how it should be undertaken.
I'm also aware that, when sharing fixtures between app and tests, changing a value of a fixture whilst developing could break tests relying on that fixture's data. What do you guys and gals think?
My primary aim is DRY fixtures - is this the correct approach? Should I be creating fixtures for tests aswell?
Many thanks!