3 ms·
> data-coupled tests I’m intrigued what this means, or how you’d decouple your tests from all data.
by plugin-baby 4y ago
> data-coupled tests
I’m intrigued what this means, or how you’d decouple your tests from all data.
- ravenstine 4y agoI can't know exactly what the OP means, but I'm guessing they're referring to the tendency for Rails tests to rely heavily on the database and its behavior. This technique is often rationalized for being a partial substitute for end-to-end testing, given that it tests the integration of the app with its services, and that's not wrong per se. It does come with a penalty because constantly building and tearing down the database has consequences in terms of performance and state leaking between test cases. A lot of the time, this reliance on the database is not (or should not) be necessary; it should be possible to test units of the application in isolation, even including the model->controller->view cycle, without needing to include any knowledge about what database or ORM are being used. Just building in-memory data on the fly is safer and faster, and when tests are faster then developers are more likely to run tests frequently and spot issues earlier. Again, as with many things, it's not a Rails-specific problem. It's an issue in many kinds of codebases, and is an issue with the Ruby community in general. I understand the arguments around coupling tests with the data layer implementation, but I just don't agree when it comes to most of the useful tests being performed.
- neon_electro 4y agoThank you for this excellent response!