News for hackers. Stuff that matters.
Re:Our Rails test suite runs in 1 minute on Buildkite by hdjjhhvvhga on Tuesday January 18, 2022 @01:40PM (#29983722)
How can you tell that if you don't know the complexity of their projects?
Re:Our Rails test suite runs in 1 minute on Buildkite by pskinner on Tuesday January 18, 2022 @02:01PM (#29984040)
This is because RoR projects do not do unit testing, they do integration testing with a real DB.

This approach is terrible and causes the poor performance.

There are whole sets of testing "tools" for RoR projects that promote this mechanism of testing - if you're testing an API you need to use an external tool to properly hit that API.

If you're writing unit tests, write unit tests with mocked dependencies.

Re:Our Rails test suite runs in 1 minute on Buildkite by ch4s3 on Tuesday January 18, 2022 @02:14PM (#29984210)
> This is because RoR projects do not do unit testing, they do integration testing with a real DB.

Lots of RoR projects do unit testing without the DB involved, I did it for ~10years and you can write small unit tests until your eyes bleed, but eventually you'll want to test the controllers.

> There are whole sets of testing "tools" for RoR projects that promote this mechanism of testing - if you're testing an API you need to use an external tool to properly hit that API.

You can just use the built in minitest tools and some fixtures to hit the API, and even back it with sqlite so it's fast and light. Most people don't because thing like Rspec, FaktoryBot, and Cuprite are convenient and nice to work with if a bit slow.

>If you're writing unit tests, write unit tests with mocked dependencies.

There were like 3 talks at Rails Conf about this, people do it all the time in Rails land.

Re:Our Rails test suite runs in 1 minute on Buildkite by pmontra on Tuesday January 18, 2022 @02:10PM (#29984166)
It's hard to really test business logic without hitting the database or other components, no matter the language and the framework. You really have to trust your mocks and sometimes you discover only in production that one of them didn't do what it should do. It happened to me.

The teams I work with tend to write unit tests to demonstrate that a class or module or whatever work, then integration tests to demonstrate that that part of the application works from the frontend code down to the database.

Re:Our Rails test suite runs in 1 minute on Buildkite by quesera on Tuesday January 18, 2022 @02:12PM (#29984182)
> This is because RoR projects do not do unit testing, they do integration testing with a real DB.

This is not correct.

Rails projects use unit testing, integration testing, and functional testing, as appropriate for the case.

Re:Our Rails test suite runs in 1 minute on Buildkite by realusername on Tuesday January 18, 2022 @02:18PM (#29984284)
If you write all yours tests without spinning up once a database, I'm not vouching for the effectiveness of said tests...

Especially that we're talking about a web framework, the db is a core part of your stack.

Yes there's going to be strictly unit tests but then at some point there are also queries and models.

Re:Our Rails test suite runs in 1 minute on Buildkite by syspec on Tuesday January 18, 2022 @09:45PM (#29989285)
Oh the number of times I've run my tests for springboot in which passed, only to fail because of a subtle db issue when hitting the real DB

I'll take hitting real "_test" db anyday

Re:Our Rails test suite runs in 1 minute on Buildkite by touisteur on Tuesday January 18, 2022 @03:47PM (#29985535)
Might be a place to bypass fsync/fdatasync via LD_PRELOAD using libeatmydata, it will save hours of CI time without switching DAO or DB configuration.