Re: Unit Testing in .Net

  • From: Dave <davidct1209@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 13 Feb 2011 20:00:08 -0800

With that said, lots of people don't follow TDD or some variant
because it does take a lot more time.  You also have to consider that
test code usually piles up *very* quickly.  You could have a few
hundred lines of code and to thoroughly test it (i.e. if you used TDD,
or if you measure code coverage), you'll need triple that in test code
or more.  Once you make any changes in the production code, you end up
spending lots of time making changes to the pile of test code.

Not to say that you shouldn't test thoroughly, but lots don't
(especially to the degree they should) for some valid reasons.  If you
can pull it off, it certainly will give your users less headaches when
trying to use your products.  It's one of those "open ended" problems;
there's reasonable points to stop writing tests, but never a "end" as
there's always some other condition you could try for an sufficiently
complex piece of software.

You also don't want to go down the road of testing user interface
components as it requires hooking deeply into OS level events (most
ironically, accessibility is useful here).


On 2/13/11, Kerneels Roos <kerneels@xxxxxxxxx> wrote:
> Thanks Dave,
>
> It is not so nice to come in afterwards and write tests for classes,
> which I'm doing now to ensure everything works right, but I can imagine
> a TDD approach could work very well indeed. As I understand it, TDD is
> also core to XP (extreme programming).
>
> For  anything new I'm going to write tests before coding and also look
> into TDD more formally. Once you know how to code and design algorithms
> one should invest in some solid software engineering techniques and get
> a good methodology to follow. I strongly believe it will save tons of
> time and produce far better software if the project is anything larger
> than a simple CRUD system.
>
> I can't decide if the book "The Art of Unit Testing" is worth the $24 or
> not though :-)
>
> Regards
>
> On 2/13/2011 8:55 AM, Dave wrote:
>> The general approach advocated by some is that of Test Driven Development.
>>
>> I have to say that whatever I've written using this approach has been
>> far more robust when it comes to quality.
>>
>> The .Net unit test frameworks of which NUnit is only one, all have
>> lots in common.  Visual Studio comes with a unit test framework as
>> well and integrates the running of tests within VS itself.  The actual
>> tool chosen is a personal choice -- if you like integration with VS
>> for example or something independent.  What tool's UI do you like,
>> etc.
>>
>> Basically, they all use .Net attributes to "markup" methods and
>> classes with metadata; think test name, test description, run time,
>> category, etc.  Then, at runtime, the runner just via reflection grabs
>> all of the tests and invokes them programmatically.
>>
>> As for TDD, if you're not familiar with it, I'd recommend looking it
>> up.  Essentially, you write tests before actually even implementing
>> anything.  The tests serve as a statement of what you expect to be
>> true.  This obviously requires that you iron out what your class
>> interface should look like; this might not be the style you're used to
>> and something C++ developers are more acustomed to.
>>
>> However, as you go along, you already have a set of validation tests
>> that verify that your stuff actually works without doing the tedious
>> pattern of compile, run, manually check if it works, and rinse/repeat.
>>
>> On 2/11/11, Jacques Bosch<jfbosch@xxxxxxxxx>  wrote:
>>> I've had good success with NUnit.
>>>
>>> On Fri, Feb 11, 2011 at 10:25 AM, Kerneels Roos<kerneels@xxxxxxxxx>
>>> wrote:
>>>
>>>> Hi, I've investigated NUnit and it'the GUI is quite accessible with JFW.
>>>> Also interested in MBUnit / Galeo but haven't tested the GUI yet. Unit
>>>> testing seems like a brilliant way to develop better code and keep it
>>>> working while changing things.
>>>>
>>>> Advantage of NUnit is that the syntax is XUnit compatible, so what you
>>>> learn there directly applies to a host of other unit test frameworks and
>>>> languages. The more advanced Galeo / MBUnit is also XUnit compatible
>>>> should
>>>> you need more power later on.
>>>> Could anyone recommend a good book on this topic / some comments of your
>>>> own experience? I hope unit testing isn't just an accademic ideal but
>>>> actually something that can be done economically.
>>>>
>>>> I found this e-book (PDF, epub and mobiM):
>>>> http://www.manning.com/osherove/
>>>> but it's from 2009 and doesn't seem to cover Galeo.
>>>>
>>>> Any comments most welcome!
>>>>
>>>> Regards,
>>>> Kerneels
>>>>
>>>> --
>>>> Kerneels Roos
>>>> Cell: +27 (0)82 309 1998
>>>> Skype: cornelis.roos
>>>>
>>>> "There are only two kinds of programming languages in the world; those
>>>> everyone complains about, and those nobody uses."
>>>>
>>>> __________
>>>> View the list's information and change your settings at
>>>> //www.freelists.org/list/programmingblind
>>>>
>>>>
>>>
>>> --
>>>
>>> Jacques Bosch
>>>
>>> Software Architecture and Development
>>> Independent Contractor
>>> Cell: +27 824711807 Fax: +27 86 504 4726
>>> E-Mail: jfbosch@xxxxxxxxx
>>>
>> __________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind
>>
>
> --
> Kerneels Roos
> Cell: +27 (0)82 309 1998
> Skype: cornelis.roos
>
> "There are only two kinds of programming languages in the world; those
> everyone complains about, and those nobody uses."
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: