On 10/26/20 9:16 AM, Vladimirs Nordholm wrote:
Hello.

I have a class which I have written some tests for, to ensure if I ever change some code it will still work as intended.

The documentation https://dlang.org/spec/unittest.html says it is can be placed both in the class or outside it.

I come from a background of having a completely separate tests folder with only tests, so I do not know what the general best-practice is with D. Where should the `unittest` code block go?

Wherever you want. Generally people put it right after the thing being tested to keep files organized.

When the compiler runs unittests it runs them all in the sequence they are in the file.

One place to be cautious though -- if you put them inside a template, they will be created for every instantiation of that template.

-Steve

Reply via email to