Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing. File structure

I have a C++ legacy codebase with 10-15 applications, all sharing several components.

While setting up unittests for both shared components and for applications themselves, I was wondering if there are accepted/common file structures for this.

Because my unit tests have several base classes in order to simplify project/customer specific test setups, there are alot of files that are common for all tests.

To me it seems natural here to create a new directory that contains all the test related files, mocks etc -to have it all centralized, and also keep testing related definitions out of the main make files.

On the other hand I see that it is common practice to have the test files reside together with the code files that they test.

Is there a more/less accepted way of doing this?

like image 932
LK__ Avatar asked Nov 09 '09 15:11

LK__


1 Answers

Out of sight, out of mind; if you keep the test files together with the code files it may be more obvious to the developers that when they update a code file they should update the tests as well.

like image 138
zac Avatar answered Sep 27 '22 17:09

zac