5 ms·
I think the bigger issue here is that new developers of Rails don't understand the best practices for testing. I switched from PHP to Ruby, then learned rails
by biznickman 14y ago
I think the bigger issue here is that new developers of Rails don't understand the best practices for testing. I switched from PHP to Ruby, then learned rails over the past year and it had a significant learning curve.
First I tried testing models and controllers, skipping views. Now I use integration tests with Capybara because it effectively tests the whole stack without writing redundant test code.
What's not clear is the pros and cons of each approach. Over time you end up using your own approach that works best for you. It's one thing to know that you need to "test your code", but with all the various testing libraries created, it can quickly become overwhelming.
In an ideal world, I'd like to learn more about the various approaches. Test::Unit vs Rspec, vs all the additional testing add-ons and how everything works together. When you end up spending just as much time writing tests as you do writing code, you quickly realize how critical getting the right approach to testing really is.
- genericsteele 14y agoMy theory is that new Rails developers spend more time learning how to test than what to test. This article isn't necessarily about which framework is better, but more about which is better as a testing learning tool. It's been pretty cool working on the testing book because I'm approaching it from a different angle. I'm not testing something, I'm showing someone how to test. I've got to dig into Test::Unit and MiniTest more than I ever have, and it's been great. There isn't a wrong way to test, so long as tests are being written.
- biznickman 14y agoThere's most definitely inefficient ways of testing. You can often cut the time of your testing if done right.
- doktrin 14y ago> First I tried testing models and controllers, skipping views. Now I use integration tests with Capybara because it effectively tests the whole stack without writing redundant test code. Does this mean you primarily rely on integration tests at the exclusion of model unit tests? If that's the case, I'm of the opinion you would be well served by revisiting your unit tests. Controller tests are kinda taken care of by integration tests, but you won't get solid coverage of your models with integration tests alone. At a minimum, model unit + integration (skipping controllers), IMHO. If for no other reason than running an integration test suite can be time consuming, and you don't always need your feedback loop to be that long.
- biznickman 14y agoI do integration tests + model tests