Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Unit testing editors and text processors
A while back, I ran a team that was working on an Open Source project, worki
ng
in an XP way.  The product was expected to parse and generate VB source code
.

In many cases, the simplest tests we could come up with still needed to pars
e
and/or generate some fairly large blocks of text that were not practical to
insert into the test code itself.  As a result of this, we ended up putting
the test input and output data into database tables instead.  This was worki
ng
OK, but it had all of the problems you'd expect from not having the test dat
a
and code together in one place.

As it happens, I may be working on another project soon with similar issues,
 a
specialized text editor.  Any advice on how to best think about writing unit
tests for this type of code?

Thanks,

Steve J.

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Jorgensen
05-16-05 01:56 PM


Re: Unit testing editors and text processors
On Sun, 15 May 2005 23:10:00 -0700, Steve Jorgensen
<nospam@nospam.nospam> wrote:

>A while back, I ran a team that was working on an Open Source project, work
ing
>in an XP way.  The product was expected to parse and generate VB source cod
e.
>
>In many cases, the simplest tests we could come up with still needed to par
se
>and/or generate some fairly large blocks of text that were not practical to
>insert into the test code itself.  As a result of this, we ended up putting
>the test input and output data into database tables instead.  This was work
ing
>OK, but it had all of the problems you'd expect from not having the test da
ta
>and code together in one place.
>
>As it happens, I may be working on another project soon with similar issues
, a
>specialized text editor.  Any advice on how to best think about writing uni
t
>tests for this type of code?

Some folks use a scheme called an Object Mother.  If you do a google
search I think you can find a writeup.  It's just a class that builds
pre-configured test data for you.


-----
Robert C. Martin (Uncle Bob)  | email: unclebob@objectmentor.com
Object Mentor Inc.            | blog:  www.butunclebob.com
The Agile Transition Experts  | web:   www.objectmentor.com
800-338-6716


"The aim of science is not to open the door to infinite wisdom,
but to set a limit to infinite error."
-- Bertolt Brecht, Life of Galileo

Report this thread to moderator Post Follow-up to this message
Old Post
Robert C. Martin
05-17-05 01:57 AM


Re: Unit testing editors and text processors
Some people store text files in the same directory as the source files.
(And these non-programming-language files don't have to just be plain
text.)

Alternately, you /can/ put lots of text into your source code, if
you're somewhat creative.  Here's a Java example:

final String[] testLines = new String[] {
"Line 1",
"Line 2",
"Line 3",
// ... //
"Line N",
};


Report this thread to moderator Post Follow-up to this message
Old Post
jeffgrigg@charter.net
05-17-05 08:57 PM


Re: Unit testing editors and text processors
jeffgrigg wrote:

> Some people store text files in the same directory as the source files.
>  (And these non-programming-language files don't have to just be plain
> text.)

Retrofitting tests lead to "characterization tests" (per Mike F.'s Legacy
Code book) that tend to fill up with large amounts of captured data, for
comparison.

I once added tests by adding module_test.cpp to each module.cpp, in the same
folder, and I tossed the test data into a sub-folder named testData. The
name was the same everywhere.

--
Phlip
[url]http://www.c2.com/cgi/wiki?ZLand[/url]



Report this thread to moderator Post Follow-up to this message
Old Post
Phlip
05-18-05 01:57 AM


Re: Unit testing editors and text processors
On Sun, 15 May 2005 23:10:00 -0700, Steve Jorgensen <nospam@nospam.nospam>
wrote:

>A while back, I ran a team that was working on an Open Source project, work
ing
>in an XP way.  The product was expected to parse and generate VB source cod
e.
>
>In many cases, the simplest tests we could come up with still needed to par
se
>and/or generate some fairly large blocks of text that were not practical to
>insert into the test code itself.  As a result of this, we ended up putting
>the test input and output data into database tables instead.  This was work
ing
>OK, but it had all of the problems you'd expect from not having the test da
ta
>and code together in one place.
>
>As it happens, I may be working on another project soon with similar issues
, a
>specialized text editor.  Any advice on how to best think about writing uni
t
>tests for this type of code?
...

Thanks to all who responded.  It took me a bit of work to understand what
Object Mother is all about, but I think I see how it's a good way to deal wi
th
the situations I'm describing.

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Jorgensen
05-18-05 08:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Extreme Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:01 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.