sw0rdfish
2008-Jun-05 19:11 UTC
Testing in Rails, uniquness of, length_of... Completeness vs. productivity
What is everyone''s feelings on this topic... I am totally onboard with testing, I feel it''s critical and the idea of Test Driven Development is growing on me,especailly after RailsConf... What I''m wondering is, how deep do you guys go? For example Rick Olsen tests the validates_presence_of in his tests in restful_authentication, however he doesn''t test the validates_uniqness_of or the validates_length_of options... My stance on it is more of an all or nothing, either you test those lines, or you trust yourself to check them yourself. The more I think about it, the more I feel tests to check all the validates_xxxxx_xxx should be done, because you might forget and delete a line, or somone else might... plus if you were doing TDD, you would say to yourself... "name has to be unique", write a test to test that... then put the line it... However here is where the other side of my brain goes "WAIT A MINUTE!"... cuz I just wrote maybe 5 or 6 lines of code, to test one line... doesn''t seem very productive. And my inner battle rages on... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
sw0rdfish
2008-Jun-06 14:24 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
anyone? Buller? On Jun 5, 3:11 pm, sw0rdfish <san...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What is everyone''s feelings on this topic... > > I am totally onboard with testing, I feel it''s critical and the idea > of Test Driven Development is growing on me,especailly after > RailsConf... > > What I''m wondering is, how deep do you guys go? > > For example Rick Olsen tests the validates_presence_of in his tests in > restful_authentication, however he doesn''t test the > validates_uniqness_of or the validates_length_of options... > > My stance on it is more of an all or nothing, either you test those > lines, or you trust yourself to check them yourself. The more I think > about it, the more I feel tests to check all the validates_xxxxx_xxx > should be done, because you might forget and delete a line, or somone > else might... plus if you were doing TDD, you would say to yourself... > "name has to be unique", write a test to test that... then put the > line it... > > However here is where the other side of my brain goes "WAIT A > MINUTE!"... cuz I just wrote maybe 5 or 6 lines of code, to test one > line... doesn''t seem very productive. > > And my inner battle rages on...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sheldon Hearn
2008-Jun-06 15:24 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 06 June 2008 16:24:02 sw0rdfish wrote:> > However here is where the other side of my brain goes "WAIT A > > MINUTE!"... cuz I just wrote maybe 5 or 6 lines of code, to test > > one line... doesn''t seem very productive.At my company, we probably spend about half our time writing test code. I''m one of the owners of the business, so the productivity of test-driven development is not academic to me. I think it''s incredibly productive. Remember, your tests act as: * a specification * a debugging framework * a refactoring safety belt * a deployment environment check If I were a customer, I would simply refuse to accept code that I didn''t feel was adequately covered by tests. Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFISVa4pGJX8XSgas0RAnlrAJwOUrY5SeaC94iWFTL3IsZIrlvcpACgrP0h +e58lyOUYLZz0YU4T8Oo5+s=PnfC -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pardee, Roy
2008-Jun-06 18:01 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
Intellectually I can understand that test-first can be more productive, and I''ve definitely wished I had a set of tests for apps after-the-fact. Yet I still have a hard time getting over the intuitive hurdle when sitting down to do something new that I should write tests first. When I read up on the testing libraries, I''m also a bit daunted by the amount of work it takes to put fixtures & mocks/stubs together. I also have a hard time thinking of things to test. I''ve heard you''re not supposed to test the framework (b/c it''s already got tests) just the stuff you write. But it seems like I''m writing the most trivial bits of the app--the framework is what does the important work. Also, being a database guy, I mostly just think in terms of data integrity when I try to come up w/things to test (e.g., I shouldn''t be able to attach a person to a non-existant organization). End of whine. ;-) -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Sheldon Hearn Sent: Friday, June 06, 2008 8:25 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 06 June 2008 16:24:02 sw0rdfish wrote:> > However here is where the other side of my brain goes "WAIT A > > MINUTE!"... cuz I just wrote maybe 5 or 6 lines of code, to test > > one line... doesn''t seem very productive.At my company, we probably spend about half our time writing test code. I''m one of the owners of the business, so the productivity of test-driven development is not academic to me. I think it''s incredibly productive. Remember, your tests act as: * a specification * a debugging framework * a refactoring safety belt * a deployment environment check If I were a customer, I would simply refuse to accept code that I didn''t feel was adequately covered by tests. Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFISVa4pGJX8XSgas0RAnlrAJwOUrY5SeaC94iWFTL3IsZIrlvcpACgrP0h +e58lyOUYLZz0YU4T8Oo5+s=PnfC -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sheldon Hearn
2008-Jun-06 18:07 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 06 June 2008 20:01:53 Pardee, Roy wrote:> I also have a hard time thinking of things to test. I''ve heard > you''re not supposed to test the framework (b/c it''s already got > tests) just the stuff you writeIf this is the thing you''re stuggling with, I _highly_ recommend trying BDD using rspec to support user stories. You can take a _lot_ of stress out of the initial stages of development by focusing on the definition, specificion and implementation of a few key user stories. Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFISXzfpGJX8XSgas0RAmP8AJ9F8gpI5hbA7+ok/5klS+hLQu8wJQCfYAQw j28nQHtSCAGixyEBCbOIpwo=Ur3I -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pardee, Roy
2008-Jun-06 18:28 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
Hmm--googling "rspec user stories" turns up these links: http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner (Wonders if this is too old to apply to the current rspec?) http://andrzejonsoftware.blogspot.com/2008/01/rspec-user-story-example.html http://peepcode.com/products/rspec-user-stories (the free preview for which does not tempt me to purchase, unfortunately). Are there other links you''d recommend? Thanks! -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Sheldon Hearn Sent: Friday, June 06, 2008 11:07 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 06 June 2008 20:01:53 Pardee, Roy wrote:> I also have a hard time thinking of things to test. I''ve heard you''re > not supposed to test the framework (b/c it''s already got > tests) just the stuff you writeIf this is the thing you''re stuggling with, I _highly_ recommend trying BDD using rspec to support user stories. You can take a _lot_ of stress out of the initial stages of development by focusing on the definition, specificion and implementation of a few key user stories. Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFISXzfpGJX8XSgas0RAmP8AJ9F8gpI5hbA7+ok/5klS+hLQu8wJQCfYAQw j28nQHtSCAGixyEBCbOIpwo=Ur3I -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ruby Freak
2008-Jun-06 19:38 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
Hi SwOrdfish. Good meeting you at RailsConf. The perceived loss of productivity will easily be recovered as the application gets larger and exponentially more difficult to debug. It''s an investment in infrastructure. I don''t like paying for insurance, but you gotta have it, and that''s what a good test suite is, insurance. I would sure rather my tests point out some embarrassing "feature" than my boss or a customer. Just my "too sense" Teedub --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
mrflip
2008-Jun-06 23:11 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
On Jun 6, 10:24 am, Sheldon Hearn <sheld...-UjuPna88SMAqcZcGjlUOXw@public.gmane.org> wrote:> Remember, your tests act as: > > * a specification > * a debugging framework > * a refactoring safety belt > * a deployment environment checkI really like that characterization. The most important aspect, to me, is documentary -- the tests codify your module''s ''interface contract''. In the beta version of restful authentication http://github.com/technoweenie/restful-authentication/tree/modular for example the field length validation *is* tested; the login name "1234567890_234567890_234567890_234567890" is expected to pass, while "1234567890_234567890_234567890_234567890_" is expected to fail: http://github.com/technoweenie/restful-authentication/tree/modular/generators/authenticated/templates/spec/models/user_spec.rb This is not, of course, to test that ActiveRecord''s validation. It is instead to clarify that this design choice was made, and that if the implementation changes you should carefully consider its interactions with other modules. You might also have tests that well outweigh some lines of code if they express a difficult tradeoff. restful_authentication specs that "encryption takes longer than #{desired_encryption_expensiveness_ms}ms to encrypt a password". As computers get faster, or if your security needs demand a change in one direction or the other, this makes you stop to weigh ''server load'', ''defense against brute force'' and ''migration complexity''. The beta restful_authentication, by the way, also includes a set of RSpec story tests and helper steps. Cheers, flip --- http://infochimps.org Connected Open Free Data --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phlip
2008-Jun-07 03:13 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
Pardee, Roy wrote:> I also have a hard time thinking of things to test...> End of whine. ;-)At my current job we use pair programming (promiscuous - in 2 hour stints). We just started a new app - Rails 2.0.2, generate a model & controller, and start TDDing. Four working days and 10 features later, we run rake stats. 80 lines of code, and 250 lines of test. 1:3 ratio, and each feature is getting better than the last. I''m like... dayam! Someone must be doing _something_ right... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sheldon Hearn
2008-Jun-07 15:52 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 06 June 2008 20:28:33 Pardee, Roy wrote:> Are there other links you''d recommend?No, you covered the important stuff that''s Rails-specific. Of course, the web is awash with commentary on testing, and as you get into rspec and or Test::Unit, you''ll find some of that commentary useful. :-) Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFISq7ZpGJX8XSgas0RAtT5AJ95xMyUB+5nfaHsMUTJ4KM2O+4m/ACfQ0Gf ioFnNuJ8YKLDqkA8lZjFadk=0olE -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phlip
2008-Jun-07 18:16 UTC
Re: Testing in Rails, uniquness of, length_of... Completeness vs. productivity
> No, you covered the important stuff that''s Rails-specific. Of course, > the web is awash with commentary on testing, and as you get into rspec > and or Test::Unit, you''ll find some of that commentary useful. :-)Google assert_latest, assert_xpath, and assert_javascript! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---