Goto Test does not work with gtest 1.8.1
Closed this issue · 8 comments
Windows 10 + VSCode 1.27.2
Test list and launch/debug works fine.
But "Go to Code" item does not work neither with googletest release-1.8.1 or master.
Is there any solutions available for that issue?
(Already read google/googletest#1658)
- install vscode
- install "C/C++ 0.18.1" (ms) extension
- install "CMake" (twxs) and "CMake Tools" (vector-of-bool) extension
- build googletest
$ git clone https://github.com/google/googletest.git && cd googletest
$ git checkout release-1.8.1
$ mkdir build && cd build && cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=Work/gtest ..
$ ninja -j6 install
5. Create simple project within vscode:
CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(testadapter)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
enable_testing()
set(GTEST_ROOT "Work/gtest")
set(GTEST_INCLUDE_DIRS "${GTEST_ROOT}/include")
set(GTEST_LIBRARY "${GTEST_ROOT}/lib/gtestd.lib")
set(GMOCK_LIBRARY "${GTEST_ROOT}/lib/gmockd.lib")
set(GTEST_MAIN_LIBRARY "${GTEST_ROOT}/lib/gtest_maind.lib")
set(GTEST_LIBS ${GTEST_LIBRARY} ${GMOCK_LIBRARY} ${GTEST_MAIN_LIBRARY})
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(testadapter main.cpp)
target_link_libraries(testadapter ${GTEST_LIBS})
main.cpp
#include <gtest/gtest.h>
#include <gmock/gmock.h>
TEST(TestAdapter, CheckOne)
{
EXPECT_TRUE(false);
}
- install gtest-adapter extension, settings.json:
{
"gtest-adapter.debugConfig": "(Windows) Launch",
"gtest-adapter.supportLocation": true
}
- build project
- testadapter run successfully with some expected output:
[----------] 1 test from TestAdapter
[ RUN ] TestAdapter.CheckOne
..\main.cpp(28): error: Value of: false
Actual: false
Expected: true
[ FAILED ] TestAdapter.CheckOne (9 ms)
-
Now. Within "Test" view press "Refresh". Everything (but "Go to Code") is fine. Test "TestAdapter/CheckOne" appear in the tree, it can be run and debug.
-
Press "Go to Code" and nothing will be happend.
@svak Thanks for reporting this issue.
I believe that version 1.2.2 fixes this issue. Could you confirm that with this new version Go to Test
does indeed work as expected, and I will then close this.
Thank you,
David
Unfortunately, after upgrading to version 1.2, the issue is not fixed.
Within Developers Tools/Console i can see that message:
"cannot open file:///../main.cpp. Detail: File not found (file:///../main.cpp)
@svak Would you mind sending me the unit test app, by mail. Also send me where Main.cpp is located relative to the workspace folder.
- google test installed to C:\Users\svak\SDK\gtest
- environment variable SDK_ROOT set to C:\Users\svak\SDK
- sample project located: C:\Users\svak\Temp\checkone
- main.cpp path: C:\Users\svak\Temp\checkone\main.cpp
Unpack to %USERPROFILE%
checkone.zip
Thank you!
@svak Could you send just the compiled executable (and the content of the build/compile_commands.json file)?
Thanks,
David
Sure,