Wrox Programmer Forums
|
BOOK: Beginning ASP.NET MVC 1.0 ISBN: 978-0-470-43399-7
This is the forum to discuss the Wrox book Beginning ASP.NET MVC 1.0 by Simone Chiaretta, Keyvan Nayyeri; ISBN: 9780470433997
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET MVC 1.0 ISBN: 978-0-470-43399-7 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2009, 09:02 PM
Registered User
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unit Testing Question

I have a question about unit testing. In general, should you try several values? I ask because in your example, you used addition for the Multiply() function to show a failing result.

But, what if you used Multiply(2, 2) and Assert.AreEqual(4, result)? The test would pass even if the code is wrong. I realize that in this simple example, it is easy to figure out that you shouldn't use 2 and 2, but in a more complex situation, I imagine it won't always be so obvious.

So, is it common testing practice to use more than one example test?
 
Old September 30th, 2009, 10:01 PM
Wrox Author
 
Join Date: Nov 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

adimauro

Please note that Simone (the author of unit testing chapter) is on travel and it may take him a few days to respond.
__________________
Keyvan Nayyeri
 
Old October 6th, 2009, 05:23 AM
Registered User
 
Join Date: Apr 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Antonio,
in general you should test a general case when you are doing the first tests (or when you are designing the application via TDD.
And then you usually need to test the boundaries cases or the the special cases.
Simo
 
Old October 7th, 2009, 12:05 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

It does bring up an important point. The purpose of TDD is to require you to do proper program development. Good requirements research, good architecture planning, etc. If you plan out your tests and find your boundary cases well, your tests will demonstrate when the code that you're writing is doing a great job or not. If you quickly dash off some haphazard tests however, you can get into all kinds of trouble. So TDD can't save you from bad programming, it just makes it more obvious when you do.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Requirement base unit testing elliscnck Assembly Language 0 February 14th, 2008 10:32 AM
Unit Testing jeffmorris BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 7 May 14th, 2007 06:51 AM
Unit Testing userrob BOOK: ASP.NET Website Programming Problem-Design-Solution 2 November 9th, 2005 10:35 AM
Unit Testing XSLT N.Todd XSLT 2 March 1st, 2005 08:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.