Definitely test. It will feel weird / slow at first, but it helps you write much cleaner, more modular code. I initially hated it when I was forcing myself to adopt it, now I feel naked without it. For me, I find testing important for a few reasons:
- It helps me think through what I want the app to do should do from a stakeholders standpoint.
- It helps me and anyone else working on my app from a dev standpoint know how my app and its components should behave - specifications should do just that: specify what certain things should do! I try to always ask myself "What should you do, Mr. [Object]" and then write a spec around that.
For example, take a look at this:
You can see what I'd expect if you were to writeUser#full_name
. It says: "Show me the full name when available, or its parts, or default to the email address, which is ensured to be present, if all else fails." Perhaps we drew up this specification when determining how we should handle displaying a"Hi, #{current_user.full_name}"
in our UI for the different cases our app might encounter. Or perhaps#full_name
was the failing part of our acceptance test when we were writing the code that we wish he had (see The RSpec Book for this reference and a very informative read). - It's an insurance policy and time saver. Anytime you change your app you can be confident that other areas still behave as expected. My workflow before TDD / BDD was:
- implement some new feature
- think through all other parts that could be effected
- pop open my dev env and manually test each to make sure things were working.
- implement some new feature
- initiate tests
- go make a sandwich, return and see what passed what needs fixing.
I found writing expressive and clean unit tests much easier than acceptance tests. If you are using Cucumber, check this out: Imperative vs Declarative scenarios in user stories and try to avoid using the pre-packaged web-steps when possible.
1 comments:
The live games offer a unique expertise to the customers by offering a real-time and practical expertise around the clock. Our back catalogue is bursting with over 1200 of the most effective on line casino games on offer, with more sizzling releases added to our rising list of on line casino games each week. And with games available to play in free mode, you can find the video slot, roulette table or jackpot game that's good for you, with out wagering 1xbet any money.
Post a Comment
Post a comment ...