Closed samwarring closed 1 year ago
I also tried a similar setup using GoogleTest and the gtest_discover_tests
command. I see the same behavior were no tests are found.
I also tried with the gtest_add_tests
command, and this did work as expected. This command computes the list of tests at configure-time by parsing the test case source files - whereas gtest_discover_tests
and catch_discover_tests
invoke the built test-binary to get the list of tests, and therefore cannot populate the full list until build-time.
I've found the easiest workaround is to simply refresh the tests in the test explorer, and that re-populates the list. However, I think this is less than ideal because that never happens automatically. To me, an easy fix would be to automatically refresh the tests after every build.
Also, I noticed other recent issues were tagged with milestones, but not this one. The only ones without them are not triaged, or "more info needed". I hope there is a plan to address this in the future. Thanks!
I can confirm that the same issue is present when using doctest_discover_tests
.
The behavior looks inconsistent. Feels like a VS Code issue. Trying to make a simplified repro...
@samwarring @stephenlevitt Could you test latest VS Code insiders (1.82.0) and check if this issue still repros?
I tried with VS Code insiders v1.82.0, and it looks like the issue is fixed. Thank you!
Now, when I choose a new configure preset, the test explorer shows "Select a test preset to discover tests." Indeed, doing so populates the test explorer. 👍
One minor issue with the latest behavior - when I add a new test to my source files, I still need to press "Refresh Tests" in order for it to appear in the test explorer. Not really a bug, but it would be great if were added automatically when I "Run all tests".
Another corner case - if I delete the build directory, I can reconfigure and rebuild everything by pressing the "Build" button in the status bar, but this will not repopulate the test explorer. Even though the project is already configured at this point, the test explorer does not update until I explicitly "CMake: Configure" the project again. I can live with this.
Thanks again!
when I add a new test to my source files, I still need to press "Refresh Tests" in order for it to appear in the test explorer.
If you find this a concern, please create a new ticket.
if I delete the build directory, I can reconfigure and rebuild everything by pressing the "Build" button in the status bar, but this will not repopulate the test explorer
I wasn't able to repro this, either using *_discover_tests()
or add_test()
. Can you provide more detailed steps?
I wasn't able to repro this, either using *_discover_tests() or add_test(). Can you provide more detailed steps?
I tried this again, and I couldn't repo either. It seems I was mistaken. Thanks for your help. I consider this issue resolved.
Brief Issue Summary
When I use Catch2's
catch_discover_tests
command, those tests don't always get populated in the test explorer, and consequently running the test cases via the CTest integration does not work.Steps to reproduce:
Expected result
The test cases are executed, and can be browsed in the test explorer.
Actual result
The output window shows "No tests were found!!!" There is one test case in the test explorer named
project_test_NOT_BUILT-b12d07c
.Analysis
The
NOT_BUILT
test case is added by Catch2'scatch_discover_tests
. If you inspect the build directory, you can find thatCTestTestfile.cmake
eventually executes:The path it's looking for does exist, but I'm guessing that vscode-cmake-tools processes this file too early, and never re-processes it after the tests are actually built.
CMake Tools Diagnostics
Debug Log
Additional Information
No response