Hacker News new | ask | show | jobs
by joevandyk 4428 days ago
I think it's impractical to test things that use ActiveRecord without testing the database.

ActiveRecord at its core is meant to generate and run SQL and give you object graphs back, and you need to test that the SQL it generates is correct and does the right thing.

2 comments

> I think it's impractical to test things that use ActiveRecord without testing the database.

I think one of the fundamental, if not really directly addressed, divides between the sides here is over the question of whether domain models "using" (being tightly coupled to) the persistence layer is sensible architecture even outside of consequences for testing.

I hope my comment that you replied to doesn't make it sound like I disagree with you. I don't. But I do think it is reasonable for other people to disagree with us on that point. But I also agree with dragonwriter that perhaps a more important question is the practicality of having fewer things that "use ActiveRecord", such that you can then test those things without testing the database. I think it's a pretty good idea, but I've had only limited success doing it in practice.