unittest which uses a disk file

Neia Neutuladh neia at ikeran.org
Wed Jan 16 22:00:01 UTC 2019


On Wed, 16 Jan 2019 21:07:24 +0000, Victor Porton wrote:
> What is the rule for unittest which uses a file (containing example data
> for testing) available only in the source distribution, not in binary
> distribution?
> 
> I am writing a library.

The easy way of doing things is to define a version for your library's 
unittests. Like I might write:

version (EpubTest) unittest
{
    writeEbookFile("test.epub");
}

And then in dub.sdl, I'd have the test configuration add
-version=EpubTest. Dub has support for this sort of thing, but I don't 
know the details offhand.

If you have extra dependencies or need extra environment setup, you might 
want to make a second dub package inside the same repository and give it a 
path-based dependency on your library. Normal people won't touch that 
second package, so you can do whatever you want there, and it's a good 
place to add another README.


More information about the Digitalmars-d-learn mailing list