I was wondering what the general best practice is for when you have multiple unit test fixtures testing different things that use the same file paths.
My test files are in a directory tree with certain rules so currently I am reusing directory macros in each file, i.e.
#define TYPE1FILE "Type1Files/" #define TYPE2FILE "Type2Files/" #define GENERIC_FILE "generic/" #define SPECIAL_FILE "special/" #define BAR1 TYPE1FILE GENERIC_FILE "/foo.txt" #define BAR2 TYPE1FILE SPECIAL_FILE "/foo2.txt" #define BAR3 TYPE2FILE GENERIC_FILE "/foo.txt" #define BAR4 TYPE2FILE SPECIAL_FILE "/foo2.txt"
However, this is starting to cause duplication in multiple files because multiple test fixtures will use the same:
#define BAR1 TYPE1FILE GENERIC_FILE "/foo.txt"
if they both use the same file.
Also, it seems like it may be better to give them some scope by using variables inside the fixture or at least within the file.
I like being able to see a list of what files are being used for each test, but I am also considering moving the BAR defines all into a shared header file. I am not crazy about that idea because it will end up being a giant list of files without any indication of what is used where. Also it couples the test cases together more.
Does anyone have any suggestions?