mattstevens / xcode-googletest Goto Github PK
View Code? Open in Web Editor NEWGoogle Test integration with Xcode
Google Test integration with Xcode
Hi there! I'd love to use this project to run my googletest tests from within Xcode, but right now I can't because this code isn't released under any sort of license for me to use it. Would you mind adding a LICENSE
or LICENSE.md
file to this repo? (see https://help.github.com/articles/adding-a-license-to-a-repository/)
Thanks!
First, this is a cool project, thanks for sharing it. (BTW, can you please add a license file so we know what the terms of usage are?)
I noticed a problem with Xcode in that after the first run of the tests (and discovering the Google tests which are added by runtime injection) it caches those suites and tests. If you add a second test to CounterTest.cpp:
TEST(Counter2, Decrement) {
Counter counter;
EXPECT_EQ(-1, counter.Decrement());
}
Now if you run GoogleTestCase again in TestNavigator it will only run the Counter test case with the initial tests (InitialState and Increment). The only workaround I found is to close the project and re-open it in XCode which causes XCode to lose all the dynamic XCTest information so when you run the GoogleTestCase if will discover (and cache) the new tests. Needless to say this is utterly annoying as I have to re-open the project any time I add/remove/disable a test.
Are you aware of this issue and if yes, do you know of a better workaround/fix?
Thanks!
Because each test method is registered separately, when I want to run a whole test case from the Test Navigator, multiple calls to RUN_ALL_TESTS() will be made (one for each test in the test case). This has the undesirable effect that SetUpTestCase & TearDownTestCase are now broken, instead of being called once per test case, they are called once per test method (just like SetUp/TearDown). I don't know how to fix this, otherwise I would have created a pull request :-)
The gtest filter allows using a test case name as a valid filter and has the desired result - runs all the enabled tests in that case. The problem I couldn't figure out is how to create a selector for the test case itself (as opposed to individual methods) that is invoked when I click the "play" arrow in the Test Navigator on the test case.
In license_test.cpp
only one test. And it looks lie this:
TEST(Test, License) {
#if !defined(WITH_LICENSE)
GTEST_SKIP();
#else
checkLicense();
#endif
}
In case, if the macro WITH_LICENSE
is not defined.
On Linux (android and windows), I am observing something like this:
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Test
[ RUN ] Test.License
[ SKIPPED ] Test.License (0 ms)
[----------] 1 test from Test (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[ PASSED ] 0 tests.
[ SKIPPED ] 1 test, listed below:
[ SKIPPED ] Test.License
But on iOS (iOS 13.4 Deployment 11.0 / arm64) it falls each time with log:
Executed 1 test, with 0 failures (0 unexpected) in 0.017 (0.017) seconds
Test Suite 'License' started at 2022-05-16 11:44:35.799
Test Case '-[Test License]' started.
.../license_test.cpp:103: error: -[Test License] : Skipped
.../ios/GoogleTests.mm:158: error: -[Test License] : ((totalTestsRun) equal to (1)) failed: ("0") is not equal to ("1") - Expected to run a single test for filter "Test.License"
Test Case '-[Test License]' failed (0.002 seconds).
Test Suite 'Test' failed at 2022-05-16 11:44:35.802.
...
** TEST EXECUTE FAILED **
Testing started on 'iPhone X black'
Compiler and build system information:
-- [polly] Used toolchain: iOS 13.4 Deployment 11.0 / arm64 / clang / c++11 support
debug CMAKE_CURRENT_LIST_DIR = /Users/admin/dev/polly
-- The C compiler identification is AppleClang 11.0.3.11030032
-- The CXX compiler identification is AppleClang 11.0.3.11030032
The version of googletest is - v1.10
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.