Reputation: 13262
Ok, n00b question. I have a cpp file. I can build and run it in the terminal. I can build and run it using clang++ in VSCode.
Then I add gtest to it. I can compile in the terminal with g++ -std=c++0x $FILENAME -lgtest -lgtest_main -pthread
and then run, and the tests work.
I install the C++ TestMate extension in VSCode. Everything I see on the internet implies it should just work. But my test explorer is empty and I don't see any test indicators in the code window.
I've obviously missed something extremely basic. Please help!
Upvotes: 4
Views: 13148
Reputation: 113
This messed with me for a while, I did as Mate059 answered above and it didn't work.
Later on I found out that the reason it didn't work was because I was using a Linux terminal inside windows (enabled from the features section) and I previously had installed the G++ compiler using the linux terminal so the compiler was turning my code into a .out
file, for some reason TestMate could not read .out files.
Once I compiled the C++ source file using the powershell terminal it created a .exe
file which I then changed the path in the setting.json as Mate059 said and it showed up.
TL;DR
Mate059 gave a great answer, go into settings.json
inside your .vscode
folder and modify "testMate.cpp.test.executables": "filename.exe"
.
For me it also worked using the wildcard *
instead of filename.exe
but I do not suggest to do that as in that might mess up something with the .exe from the main cpp file and what not.
Upvotes: 0
Reputation: 49
I'd say, never assume something will "just work".
You'll still have to read the manual and figure out what are the names of config properties. I won't provide exact examples, because even though I've only used this extension for a short time, its name, and therefore full properties path, has already changed, so any example might get obsolete quite fast.
The general idea is: this extension monitors some files/folders, when they change, it assumes those are executables created using either gtest
or catch2
. The extension tries to run them with standard (for those frameworks) flags to obtain a list of test suites and test cases. If it succeeds, it will parse the output and create a nice list in the side panel. Markers in the code are also dependent on the exactly same parsed output, so if you have one, you have the other as well.
From the above, you need 3 things to make this work:
gtest
implementation parses and processes its standard flags, extension will fail to parse the output of ./your_test_binary --gtest-list_tests
.To troubleshoot #2 and #3 you can turn on debug logging for the extension (again, in the VSCode's config json), this will cause an additional "Output" tab/category to be created, where you can see, which files were considered, which were run, what was the output, and what caused this exact file to be ignored.
Upvotes: 4
Reputation: 123
Executables should be placed inside the out
or build
folder of your workspace. Or one can modify the testMate.cpp.test.executables
config.
Upvotes: 5