-
Notifications
You must be signed in to change notification settings - Fork 229
Few questions regarding your approach #50
Comments
In a real project, I would typically not test this as heavily in the controller if the functionality had been moved to another object. However I like writing these tests for the sake of demonstrating how controller tests work, and practicing writing tests in general. They're also useful if my code is doing something unexpected and I want to test user input without spinning up a full feature test—could be that something is causing different values to be passed to
It's going to depend. I'm not the right person to ask about an "acceptable" length of time for tests to run, because I'm more interested in making sure I have reliable test coverage for the important parts of my application. I have test suites that run in under a second. I work on one that take 20+ minutes. As I mention in the book, yes, you can speed this up considerably by relying on unit tests and mocking out implementation details—but that can get you in trouble if your mock behaves differently than the object or service it's pretending to be. If you're an experience developer, then go for it. If you're a newcomer, focus on writing good tests first, then fast tests later.
If you're writing the tests after you've written the code, then it's probably not necessary. Shoulda and tests like these in general are useful to me when I am practicing TDD and thinking about how an object I'm creating needs to behave.
Yeah, that seems like a reasonable approach to me. |
Hi Aaron, I've just finished to read your book and it was very useful to clarify some doubts I had on rails testing.
I have few remaining questions for you:
Thank you!
The text was updated successfully, but these errors were encountered: