Why think unit tests should be in their own source code hierarchy instead of side-by-side
Tony
tonytdominguez at aol.com
Fri Mar 23 21:45:33 UTC 2018
On Friday, 23 March 2018 at 20:43:15 UTC, H. S. Teoh wrote:
>
>> I've worked on a project where the testing was separated from
>> the code, and it was a liability IMO. Things would get missed
>> and not tested properly.
That's where Test Driven Development comes in.
>
> Yep. As I mentioned elsewhere, recently I've had to resort to
> external testing for one of my projects, and I'm still working
> on that right now. And already, I'm seeing a liability: rather
> than quickly locating a unittest immediately following a
> particular function, now I have to remember "oh which
> subdirectory was it that the tests were put in? and which file
> was it that a particular test of this function was done?". It's
> an additional mental burden to have to keep doing the mapping
> between current source location <-> test code location (even if
> it's a 1-to-1 mapping), and a physical burden to have to
> continually open external files (and typing a potentially long
> path for them) rather than just "bookmark, jump to end of
> function, navigate unittest blocks" in the same file.
There are pluses and minuses to both approaches, but I don't
think that a separate file approach is as difficult as you are
suggesting. The naming is typically identical to the project
entities being tested, with a prefix like "Test_" tacked onto
the front of the project, modules, classes and functions, making
finding things straightforward. And most modern editors/IDEs will
allow multiple files and projects to be open at the same time,
allowing test code to be opened only once per coding session.
More information about the Digitalmars-d-announce
mailing list