How to unit-test behavior under "version"?

Steven Schveighoffer schveiguy at gmail.com
Wed Mar 30 01:03:04 UTC 2022


On 3/29/22 8:57 PM, Andrey Zherikov wrote:
> On Tuesday, 29 March 2022 at 20:20:46 UTC, Steven Schveighoffer wrote:
>> So keep in mind that versions are *module-wide*, and usually 
>> *compilation-wide*. Which means that you won't be testing multiple 
>> version configurations in the same build.
>>
>> ...
>>
>> In the case where version is going to *affect the results of the 
>> function*, as yours does above, then what I would do is repeat the 
>> version tree as above, putting an individual unittest in each branch. 
>> But you could potentially do it inside the unittest itself. I just 
>> find that a bit convoluted.
> 
> Right, I can do per-version unit tests and the question becomes how to 
> build&run all versions. Since I'm using dub, there is a way to express 
> different versions through "configuration" specs in dub.json. Is there a 
> way to tell `dub test` to test all configurations?
> 

I don't think so. I think you need to run all the configurations one at 
a time.

-Steve


More information about the Digitalmars-d-learn mailing list