I have a rather large Visual Studio solution file containing many project files below it. Each of these projects holds C files and header files along with unit tests, and compiles to an executable or library. Also, each unit test compiles to its own executable.
├───Solution
│ ├───project1
| | |───some_code.c
| | |───more_code.c
│ │ └───unit_tests
| | |───test_some_code.c
| | |───test_more_code.c
│ │ └───results
| ├───project2
| | |───even_more_code.c
│ │ └───unit_tests
| | |───test_even_more_code.c
│ │ └───results
⋱ ⋱
Is there a way to configure a corresponding executable for each of these unit tests? I can see the target for the entire project: But I don't see a corresponding option for an individual file:
Goal: Clicking 'Debug' while viewing any test source code debugs the corresponding unit test executable.
It seems like a XY problem.
Maybe we can offer a better solution so we don't need to achieve the goal in a way like:Clicking 'Debug' while viewing any test source code debugs the corresponding unit test.
In VS IDE, we can configure our new configuration. So you can right-click project=>Configuration Manager or go this way to open the manager:
In Active solution configurations choose new and set settings like below and click ok:
After that,for every project in your solution, you can configure their corresponding configuration for debugging unit tests.
E.g:
Don't forget to configure other related settings in this page like pdb file name.
When you try to debug project1, set it as startup project, set the configuration to Debug and F5. When trying to debug project1-unit-test, set the configuration to DebugForTest and F5.