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 is a C mocking library.
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 ../
cmake --build .
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.
In order to build the tests use the run_unittests cmake option:
cmake .. -Drun_unittests:bool=ON
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!
Complete documentation is available here.