Tempfiles in unittests

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 12 08:11:47 PDT 2012


On Mon, Mar 12, 2012 at 01:54:08PM +0100, Magnus Lie Hetland wrote:
> On 2012-03-11 21:14:59 +0000, Jonathan M Davis said:
> 
> >So, as far as Phobos' unit tests are  concerned, there's not
> >really any need for what you're trying to do.
> 
> Sure. Just would have thought that maybe some unit-testing D user out
> there had written a function that wrote something to a file ;-)
[...]

I've written unittests that create files to test code with.

However, I never thought far enough to make it something generic that
can be used elsewhere. :-) So I use actual filenames (not tmpfiles) so
that later unittests can reference actual filenames to load different
datasets into the program for testing. Not the nicest solution, since it
will overwrite files in the working directory, but presumably only
developers will bother running unittests anyway so this shouldn't be a
problem.


T

-- 
Truth, Sir, is a cow which will give [skeptics] no more milk, and so
they are gone to milk the bull. -- Sam. Johnson


More information about the Digitalmars-d-learn mailing list