googletest

Android NDK with Google Test

只愿长相守 提交于 2019-11-28 21:37:58
I'm trying to use GoogleTest on Android Studio. According to what I understood, the latest version of NDK has the gtest included. I did not find a clear guide how to do it. I followed this document: So, I opened a new project, created jni folder and the following files (inside the files I wrote exactly what the document): But it does not recognize the #include gtest/gtest.h In addition, how to run the adb at the end? I created an android.mk file but where should I call it? If you choose cmake to drive your externalNativeBuild (and this is the preferred option, according to Android Developers

CMake cannot find GoogleTest required library in Ubuntu

橙三吉。 提交于 2019-11-28 21:27:24
Similar issue here . This is my CMakeLists.txt: cmake_minimum_required(VERSION 2.6) # Locate GTest find_package(GTest REQUIRED) include_directories(${GTEST_INCLUDE_DIRS}) # Add test cpp file add_executable(foo foo.cpp) # Link test executable against gtest & gtest_main target_link_libraries(foo ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread) And my foo.cpp: #include <gtest/gtest.h> TEST(sample_test_case, sample_test) { EXPECT_EQ(1, 1); } int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } Now, all works fine when using the g++ compiler. However,

Linking to multiple .obj for unit testing a console application

给你一囗甜甜゛ 提交于 2019-11-28 20:54:29
Having a few issues and hope I can find some help. I have two projects under the same solution in Visual Studio 2012 A bit of background I cam creating a console application which outputs as a .exe this is in one project. In another project I have google test set up to run unit tests on the classes in the console application project. If I was able to compile the main project into a static library there wouldn't be an issue due to could link to the .lib, however this isn't an option. I have found that linking to the .obj works however I need to manually enter each one into the linker -> input

How to capture stdout/stderr with googletest?

淺唱寂寞╮ 提交于 2019-11-28 17:11:48
Is it possible to capture the stdout and stderr when using the googletest framework? For example, I would like to call a function that writes errors to the console (stderr). Now, when calling the function in the tests, I want to assert that no output appears there. Or, maybe I want to test the error behaviour and want to assert that a certain string gets printed when I (deliberately) produce an error. I have used this snippet before to redirect cout calls to a stringstream when testing output. Hopefully it might spark some ideas. I've never used googletest before. // This can be an ofstream as

using googletest in eclipse: how?

限于喜欢 提交于 2019-11-28 15:54:24
I've downloaded google test, but now I've no idea on how to link it to my project in eclipse. Should I add it as a source folder? Should include it as g++ included library? And how can I run test then? Josh Glover Using Riga's excellent answer , here is a summary of how I got it to work: Created a new C++ project in Eclipse (I chose Executable > Empty Project) Downloaded googletest 1.5.0 , untarred, and ran ./scripts/fuse_gtest_files.py . <project-dir>/contrib Back in Eclipse, excluded the contrib directory from the Release build configuration, and added <project-dir>/contrib to the include

What is the best way of testing private methods with GoogleTest? [closed]

江枫思渺然 提交于 2019-11-28 15:38:28
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I would like to test some private methods using GoogleTest. class Foo { private: int bar(...) } GoogleTest allows a couple of ways of doing this. OPTION 1 With FRIEND_TEST : class Foo { private: FRIEND_TEST(Foo, barReturnsZero); int bar(...); } TEST(Foo, barReturnsZero) { Foo

What unit-testing framework should I use for Qt? [closed]

独自空忆成欢 提交于 2019-11-28 15:35:18
I am just starting up a new project that needs some cross-platform GUI, and we have chosen Qt as the GUI-framework. We need a unit-testing framework, too. Until about a year ago we used an in-house developed unit-testing framework for C++-projects, but we are now transitioning to using Google Test for new projects. Does anyone have any experience with using Google Test for Qt-applications? Is QtTest/QTestLib a better alternative? I am still not sure how much we want to use Qt in the non-GUI parts of the project - we would probably prefer to just use STL/Boost in the core-code with a small

Jenkins Build Script exits after Google Test execution

被刻印的时光 ゝ 提交于 2019-11-28 11:21:06
I am building a Qt GUI application via Jenkins. I added 3 build steps: Building the test executable Running the test executable compiling a coverage report with gcovr For some reason, the shell task for running the test executable stops after execution. Even a simple echo does not run after. The tests are written with Google Test and output xUnit XML files, which are analyzed after the build. Some tests start the applications user interface, so I installed the jenkins xvnc plugin to get them to run. The build tasks are as follows: Build cd $WORKSPACE/projectfiles/QMake sh createbin.sh Test cd

Reducing output of gtest, to look similar to output of cxxtest

你离开我真会死。 提交于 2019-11-28 11:14:08
问题 I have a set of unit tests using gtest as framework. Build, and execute, and the output looks like this : I'd like to have the output similar to the output when using cxxunit ( . when test pass, detail error when it fails). If possibly, with colors. How to do this? If I wasn't clear, I am looking for code and exact way how to do this. The output should be something like : Executing dummy_tests ..... ../code/app/unit_tests/unittest_dummy.cpp:25: Failure Value of: 2 Expected: 1 .. FAILED I am

googletest Undefined symbols for architecture x86_64 error

北城以北 提交于 2019-11-28 11:07:21
问题 Let GTEST_DIR be the environment variable storing the path to the googletest directory. (I cloned googletest-master from googletest's github repo.) I cd 'ed into $GTEST_DIR , did a mkdir build && cd build , then executed the following command : cmake .. -DCMAKE_C_COMPILER=$GNU-6.0.0/bin/gcc-6.0.0 -DCMAKE_CXX_COMPILER=$GNU-6.0.0/bin/g++-6.0.0 where GNU-6.0.0 is the path to my gnu install. This generated a Makefile inside $GTEST_DIR/build that I tweaked as follows : I've added CC = $GNU-6.0.0