All Projects → macmade → gmock-xcode

macmade / gmock-xcode

Licence: MIT License
Xcode integration for GoogleMock through XCTest

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to gmock-xcode

emock
🐞 下一代C/C++跨平台mock库 (Next generation cross-platform mock library for C/C++)
Stars: ✭ 73 (+305.56%)
Mutual labels:  gmock, googlemock, gtest
Telegraf-Test
Telegraf Test - Simple Test ToolKit of Telegram Bots
Stars: ✭ 22 (+22.22%)
Mutual labels:  test, testing-tools
api-test
🌿 A simple bash script to test JSON API from terminal in a structured and organized way.
Stars: ✭ 53 (+194.44%)
Mutual labels:  test, testing-tools
BaseUrlManager
⛵ BaseUrlManager的设计初衷主要用于开发时,有多个环境需要打包APK的场景,通过BaseUrlManager提供的BaseUrl动态设置入口,只需打一次包,即可轻松随意的切换不同的开发环境或测试环境。在打生产环境包时,关闭BaseUrl动态设置入口即可。
Stars: ✭ 43 (+138.89%)
Mutual labels:  test, testing-tools
ja-rule
Ja Rule is the code behind OLE, an Open Source DMX/RDM framework for PIC32 microcontrollers
Stars: ✭ 36 (+100%)
Mutual labels:  gmock, gtest
generator-react-jest-tests
A React Jest test generator. Generates snapshot tests for React components.
Stars: ✭ 34 (+88.89%)
Mutual labels:  test, testing-tools
sushi
The SUSHI test case generator
Stars: ✭ 19 (+5.56%)
Mutual labels:  test, testing-tools
scalatest-junit-runner
JUnit 5 runner for Scalatest
Stars: ✭ 30 (+66.67%)
Mutual labels:  test, testing-tools
qiniutest
Qiniu httptest tool: qiniutest
Stars: ✭ 36 (+100%)
Mutual labels:  test, testing-tools
Wasmite
Now WebAssembly has proper testing, unit-testing and debugging 🤗
Stars: ✭ 20 (+11.11%)
Mutual labels:  test, testing-tools
carina-demo
Carina demo project.
Stars: ✭ 40 (+122.22%)
Mutual labels:  test, testing-tools
CombineExpectations
Utilities for tests that wait for Combine publishers
Stars: ✭ 204 (+1033.33%)
Mutual labels:  test, xctest
Orion-Stress-Tester
A simple, efficient and accurate stress tester, support HTTP, WebSocket and TCP
Stars: ✭ 32 (+77.78%)
Mutual labels:  test, testing-tools
eaf-linter
🤪 A linter, prettier, and test suite that does everything as-simple-as-possible.
Stars: ✭ 17 (-5.56%)
Mutual labels:  test, testing-tools
laika
Log, test, intercept and modify Apollo Client's operations
Stars: ✭ 99 (+450%)
Mutual labels:  test, testing-tools
IO-TESTER
A functional test framework
Stars: ✭ 32 (+77.78%)
Mutual labels:  test, testing-tools
threat9-test-bed
No description or website provided.
Stars: ✭ 26 (+44.44%)
Mutual labels:  test, testing-tools
playwright-test
Run unit tests with several runners or benchmark inside real browsers with playwright.
Stars: ✭ 81 (+350%)
Mutual labels:  test, testing-tools
xray-action
... a GitHub action to import test results into "Xray" - A complete Test Management tool for Jira.
Stars: ✭ 16 (-11.11%)
Mutual labels:  test, testing-tools
how-to-qemu-arm-gdb-gtest
How to run, debug, and unit test ARM code on X86 ubuntu
Stars: ✭ 19 (+5.56%)
Mutual labels:  gmock, gtest

GoogleMock - Xcode

Build Status Issues Status License
Contact Sponsor

About

This project consists of an integration of the GoogleMock library to Apple's Xcode IDE.

Since version 5, Xcode provides a nice way to write unit tests with the XCTest framework.
Unit tests written with XCTest are integrated to the IDE, providing visual feedback when running tests. They are also integrated with the different build toolchains, like xcodebuild or Facebook's xctool.

It was specifially designed for Objective-C, writing unit tests for other languages (such as C++) is not so great with XCTest. Of course, this is possible using Objective-C++, but writing an Objective-C class for each C++ test case leads to some undesired overhead.

GoogleMock is nice unit testing library for C++. The only issue is that it does not integrate well with Xcode, as does XCTest.
This mean the IDE won't provide visual feedback for the unit tests written with GoogleMock, and you'll have to look at the console output to inspect any failed test.

So this project fixes this issue by bridging GoogleMock to XCTest.

Implementation details

XCTest works by analysing test classes at runtime, thanks to Objective-C dynamic nature.
Basically, when the test bundle is loaded, it will look for all classes extending XCTestCase, and look for methods beginning with the test prefix.

If such a class is available, it will then create an instance, and launch each test method, reporting the result to the IDE.

This project consists of a framework which has to be linked to the unit test bundle. The framework includes GoogleMock, so you don't have to build it by yourself.

It works by querying each GoogleMock test case. For each one, a specific subclass of XCTestCase will be dynamically created at runtime.
For each test in a test case, an Objective-C method will be created and added to the XCTestCase subclass.

The GoogleMock test cases are then run, reporting the usual output to the console.

Then, as we created new classes compatible with XCTest, it will find them, and run them as usual.
Each method will simply look at the GoogleMock test result, and report the status using XCTest assertions, so we got visual feedback, as if we had written our test cases using XCTest.

Project Configuration

In order to use these features, your unit test bundle needs to be linked to the provided frameworks.

The easiest way to do this is to include the provided Xcode project (GoogleMock.xcodeproj) as a subproject of your own Xcode project, so all targets are available.

Then, from the Build Phases screen of your unit test's target, add the following frameworks to the Target Dependancies step:

  • GoogleMock

Adds the same frameworks to the Link Binary With Libraries step, and you're done.
Your unit test bundle is now ready to use GoogleMock.

Writing tests

Writing GoogleMock tests is also straightforward.
Simply include <GoogleMock/GoogleMock.h> to your .cpp file, and write your tests as usual.

For instance:

#include <GoogleMock/GoogleMock.h>

using namespace testing;

TEST( MyTestCase, MyTest )
{
    ASSERT_TRUE( true );
}

In the above example, a subclass of XCTestCase named MyTestCase will be created at runtime, with a test method called testMyTest, so you can easily inspect the results of your GoogleMock tests directly from the Xcode tests tab.

License

The GoogleMock Xcode integration library is released under the terms of the MIT License.

Repository Infos

Owner:			Jean-David Gadina - XS-Labs
Web:			www.xs-labs.com
Blog:			www.noxeos.com
Twitter:		@macmade
GitHub:			github.com/macmade
LinkedIn:		ch.linkedin.com/in/macmade/
StackOverflow:	stackoverflow.com/users/182676/macmade
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].