I want to establish "best-practices" as well as "reasonable baby-steps" for getting legacy projects to use unit-tests, modernize, and decouple unnecessary dependencies.
I found googletest to be a reasonable testing framework for writing unit tests. Getting it to work on existing code in visual studio is way too hard.
- Is it necessary for googletest to be its own project?
/fooApp/foo/foo.vcxproj
/fooApp/foo.test/foo.test.vcxproj
I found that this requires many changes for the test project to work.
- .cpp files need to be added by hand with a relative path
- precompiled headers and stdafx.h conflict with the test project
unresolved symbols require adding more code into the test project
- Can google test just be added to the existing project? As a build Configuration
Is this even possible? I'd much rather have this than make in a new project.
/foo/fooDoc.h
/foo/fooDoc.cpp
/foo/fooDoc.t.cppdebug
release
unit test
Any guidance about using googletest in a visual cpp project would be appreciated. I can write tests, I just want the configuration to be less painful.
edit: Here are a few more examples of things I tried with varying success
- put foo.test.vcxproj in same folder as the foo.vcxproj this will make various folders collide and fail
- use the same stdafx.h for pre-compiled headers, requires adding a path the the include folder, requires changing both projects
- have stdafx.h include pch.h, requires #ifdefs and other changes. ( missing win_sdk_ver)
- getting no tests found error. starting over.