Integration test or isolated test?


I am using isolated tests for all my classes except for models and feature’s specs. I do it because it’s fast. I do 444 specs in 30 seconds. I see all learn.thoughtbot’s specs are made with integration tests.

I think isolated tests are fasts but integration tests are simple.

What is you opinion on this subject. Do you prefer integration or isolation?

Integration tests are slow because it hit the database. I think a way to avoid the hit of database can be the best of both world. Is there a way to do this?

For Rails app I do not do tests in isolation because I do not know how to do it ;). I use integration (models with all dependencies) and feature specs (testing the app).

For my other pure Ruby project I test everything in isolation and I like it. The only drawback is that currently I use test doubles, but it can happen that they do not reflect real interface of doubled object.

Do you test controllers?

Do you have an open source example of your code? Thanks!

I do not test controllers, but probably I will start with it in my next project. Right now I do not have any experiences with controller tests.

Anyway I have 2 rails apps on my github:

So you can check how I test. And also any comments are welcome.

I saw your projects. They are clean but it’s difficult to say how it can be done with a complex project because your applications seems to be small. I’m interested to see how you can manager services, form objects and all that kind of complex logic.

I think you did a nice work for your projects.