Hi, Who here user Unit Test and can give some tips about when use it or not?? Some people think that it is time lost.... It is needed in what type of projects?? Thank you -- Pedro C. Valentini pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org +55 (21) 8708-8035
I''m a firm believer in extensively testing my projects. It doesn''t always work out that way, but that''s what I strive for. If you''re going for speed, tests will slow you down a lot, however. But if you''re maintaining, squashing bugs, or making iterative improvements, nothing else gives you that feeling of confidence that everything is working. On 6/30/05, Pedro Valentini <pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org> wrote:> Hi, > Who here user Unit Test and can give some tips about when use it or not?? > Some people think that it is time lost.... > It is needed in what type of projects?? > > Thank you > > -- > > Pedro C. Valentini > pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org > +55 (21) 8708-8035 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- rick http://techno-weenie.net
On Thursday 30 June 2005 21:10, Pedro Valentini wrote:> Who here user Unit Test and can give some tips about when use it or > not?? Some people think that it is time lost.... > It is needed in what type of projects??The easy answer is: always. The reason is that with unit tests it is easier to check your freshly (or even not yet) implemented functionality and immensely easier to assure that you haven''t broken anything with your recent changes. The alternative in both cases is manually exercising the application and checking its output. This works for a one time check, but for evolving code that''s not worth much. Thus, manual testing becomes burdensome and error-prone. Also, tests purely at the outer edges of an app -- UI, database contents -- are not always enough to ensure that it''s functioning properly. In my use of various languages and frameworks I''ve noticed a pattern. When I first learn a new thing, I want to program ahead without any tests, just get some code written and get a feelings for the environment. Invariably, there comes a point where I start to feel squirmish about the code and manual testing becomes a burden. That''s when I start to look into how unit testing is done in the environment. Rails already provides an excellent infrastructure for unit as well as functional tests. Getting started with it isn''t complicated at all. I''ve come to scratch my head recently on how to test code that is rather generic, not tied to a particular application, or interacts closely with Rails code. It''s definitely possible, as the example of Rails itself shows. It just takes more time to figure out how to do it... Michael -- Michael Schuerig This is not a false alarm mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org This is not a test http://www.schuerig.de/michael/ --Rush, Red Tide
You are living in the stone ages if you do not unit/functional test your apps. This is coming from a person who had no idea what unit testing was 3 months ago. The time you take to unit test your apps will be much quicker than the time it takes to manually debug a problem found 6 months after your app goes live. Not to say that unit tests will get rid of every possible bug, but you will definitely have much fewer bugs in the long run. Another great thing about unit testing is that it helps you to find weaknesses in your code, such as not following a design pattern. Since after all, a unit test is just a client using your app. Hope this helps, Jin On 6/30/05, Michael Schuerig <michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org> wrote:> On Thursday 30 June 2005 21:10, Pedro Valentini wrote: > > > Who here user Unit Test and can give some tips about when use it or > > not?? Some people think that it is time lost.... > > It is needed in what type of projects?? > > The easy answer is: always. > > The reason is that with unit tests it is easier to check your freshly > (or even not yet) implemented functionality and immensely easier to > assure that you haven''t broken anything with your recent changes. The > alternative in both cases is manually exercising the application and > checking its output. This works for a one time check, but for evolving > code that''s not worth much. Thus, manual testing becomes burdensome and > error-prone. Also, tests purely at the outer edges of an app -- UI, > database contents -- are not always enough to ensure that it''s > functioning properly. > > In my use of various languages and frameworks I''ve noticed a pattern. > When I first learn a new thing, I want to program ahead without any > tests, just get some code written and get a feelings for the > environment. Invariably, there comes a point where I start to feel > squirmish about the code and manual testing becomes a burden. That''s > when I start to look into how unit testing is done in the environment. > Rails already provides an excellent infrastructure for unit as well as > functional tests. Getting started with it isn''t complicated at all. > > I''ve come to scratch my head recently on how to test code that is rather > generic, not tied to a particular application, or interacts closely > with Rails code. It''s definitely possible, as the example of Rails > itself shows. It just takes more time to figure out how to do it... > > Michael > > -- > Michael Schuerig This is not a false alarm > mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org This is not a test > http://www.schuerig.de/michael/ --Rush, Red Tide > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Thursday 30 June 2005 03:10 pm, Pedro Valentini wrote:> Hi, > Who here user Unit Test and can give some tips about when use it or not?? > Some people think that it is time lost.... > It is needed in what type of projects?? >The only time you should write unit tests, is when you want your code to work correctly. :) While it may *appear* to take more time, once the skill is developed, it saves time. But, it is a skill, and it does take time to become good at it. David
To take that a step further, when you write the tests first (another skill that takes some time get cozy with) you save even more time because your methods get written in response to client calls. The result is inherently more testable code and less time spent figuring out how you''re going to test a method. -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of David Corbin Sent: Thursday, June 30, 2005 6:37 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] Unit Test Experience, who use ? On Thursday 30 June 2005 03:10 pm, Pedro Valentini wrote:> Hi, > Who here user Unit Test and can give some tips about when use it or not?? > Some people think that it is time lost.... > It is needed in what type of projects?? >The only time you should write unit tests, is when you want your code to work correctly. :) While it may *appear* to take more time, once the skill is developed, it saves time. But, it is a skill, and it does take time to become good at it. David _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 6/30/05, David Chelimsky <david-KlVyb9BshxjEY7qOzZUwZA@public.gmane.org> wrote:> To take that a step further, when you write the tests first (another skill > that takes some time get cozy with) you save even more time because your > methods get written in response to client calls. The result is inherently > more testable code and less time spent figuring out how you''re going to test > a method.I really liked Ben Griffiths'' approach to testing: http://www.reevoo.com/blogs/bengriffiths/2005/06/24/a-test-by-any-other-name/ Basically, he names the test methods a certain way, and has a rake task to generate a simple text file based on that. If you''re into design by contract stuff at all, he''s generating object contents from his test suites. Pretty cool stuff. -- rick http://techno-weenie.net
Le 05-06-30 à 13:10, Pedro Valentini a écrit :> Hi, > Who here user Unit Test and can give some tips about when use it or > not?? > Some people think that it is time lost.... > It is needed in what type of projects??You can get away without testing in a language with static type checking like C++ or Java, but with a language like Ruby, you must have tests, or your code will likely run you into the ground. david> > Thank you > > -- > > Pedro C. Valentini > pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org > +55 (21) 8708-8035 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 7/26/05, David Geary <sabreware-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote:> Le 05-06-30 à 13:10, Pedro Valentini a écrit : > > > Hi, > > Who here user Unit Test and can give some tips about when use it or > > not?? > > Some people think that it is time lost.... > > It is needed in what type of projects?? > > You can get away without testing in a language with static type > checking like C++ > or Java, but with a language like Ruby, you must have tests, or your > code will > likely run you into the ground.I don''t think static languages give you /that/ much safety. All it checks is that you''re not messing anything up type-related, like putting a float in an array of ints or something.
> You can get away without testing in a language with static type > checking like C++ > or Java, but with a language like Ruby, you must have tests, or your > code will > likely run you into the ground.I have to disagree there david, you can''t really get by without it in java either. The compiler only catches extremely basic errors which are easily found with a few seconds testing. Take: public void setCustomer(Customer c) {} public Customer getCustomer() { return null; } //... blah.getCustomer().getFirstName(); // BOOM Or: List theList = new ArrayList(); theList.add(new Customer()); //... String s = (String)theList.get(0); Testing is a great idea, I''m not a fan of test-first development, but a codebase without tests is dangerous, in any language. -- Cheers Koz