Giter VIP home page Giter VIP logo

umock-c's Introduction

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

umock_c

umock_c is a C mocking library.

Setup

Build

  • Clone umock_c by:
git clone --recursive https://github.com/Azure/umock-c.git
  • Create a cmake folder under the root of umock-c

  • Switch to the cmake folder and run

cmake ..

If you would like to use installed (by CMake) versions of packages already on your machine:

cmake -Duse_installed=ON ../
  • Build the code for your platform (msbuild for Windows, make for Linux, etc.) by executing in the cmake folder:
cmake --build .

To install umock_c:

cmake -Duse_installed=ON ../

On Linux:

sudo make install

On Windows:

msbuild /m INSTALL.vcxproj

This requires that ctest and testrunnerswitcher are both installed (through CMake) on your machine.

Building tests

In order to build the tests use the run_unittests cmake option:

cmake .. -Drun_unittests:bool=ON

Example

Ever wanted to write something like this in C as a test?

TEST_FUNCTION(my_first_test)
{
    // arrange
    STRICT_EXPECTED_CALL(test_dependency_1_arg(42))
        .SetReturn(44)
        .IgnoreAllArguments();

    // act
    int result = function_under_test();

    // assert
    ASSERT_ARE_EQUAL(int, 44, result);
    ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}

umock_c has way more features than this simple example!

Dependencies

  • umock_c uses ctest as test runner (https://github.com/Azure/azure-ctest.git). ctest is a C test runner that can be run on many platforms as it does not make use of compiler/platform specific code and thus it is easily portable.
  • umock_c uses cmake (https://cmake.org/) to generate build files.
  • umock_c uses testrunnerswitcher to allow switching between ctest and CppUnitTest for Windows.

Documentation

Complete documentation is available here.

umock-c's People

Contributors

andrew-buckley avatar anporumb avatar aribeironovaes avatar arsing avatar damonbarry avatar dandrestor avatar danewalton avatar dcristoloveanu avatar ewertons avatar jebrando avatar jetstreamroysprowl avatar jspaith avatar jtanner-msft avatar mamokarz avatar marcschier avatar mattdurak avatar mrohera avatar sahithkallakunta avatar saidfathelbab avatar ttins avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.