Why think unit tests should be in their own source code hierarchy instead of side-by-side

Tony tonytdominguez at aol.com
Sat Mar 24 00:51:07 UTC 2018


On Saturday, 24 March 2018 at 00:12:23 UTC, Jonathan M Davis 
wrote:
> On Friday, March 23, 2018 22:42:34 Tony via 
> Digitalmars-d-announce wrote:
>> On Friday, 23 March 2018 at 22:32:50 UTC, H. S. Teoh wrote:
>> > On Fri, Mar 23, 2018 at 09:45:33PM +0000, Tony via
>> >
>> > Digitalmars-d-announce wrote:
>> >> On Friday, 23 March 2018 at 20:43:15 UTC, H. S. Teoh wrote:
>> >> > On Friday, 23 March 2018 at 19:56:03 UTC, Steven
>> >> >
>> >> > Schveighoffer 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.
>> >
>> > That's not an option when you have an existing codebase that 
>> > you have to work with.  You basically have to start out with 
>> > tons of code and no tests, and incrementally add them.  
>> > Having to also maintain a separate test tree mirroring the 
>> > source tree is simply far too much overhead to be worth the 
>> > effort.
>>
>> I think that you could "Test Driven Develop" the code you are 
>> adding or changing.
>
> Insisting on writing the tests before writing the code doesn't 
> help with the kind of situation that H. S. Teoh is describing. 
> And arguably it exacerbates the problem. Regardless, it doesn't 
> help when the code has already been written.

I don't see how it exacerbates it and I don't see how it doesn't 
help. The point of Test-Driven Development it to make sure you 
have written a test for all your code. You can also do 
test-driven development in unittest blocks.

But as far as whether or not it can be done with maintenance 
code, my original reply that mentioned it was to someone who 
appeared to be talking about a new project not getting everything 
tested, not a maintenance project. So saying "can't do it for 
maintenance" doesn't even apply to my reply.




More information about the Digitalmars-d-announce mailing list