Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Apr 1, 2023
2 parents 833e4ce + 0cb7a75 commit 5b131db
Show file tree
Hide file tree
Showing 25 changed files with 232 additions and 1,007 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/ci_linux_clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ jobs:
- uses: actions/checkout@v2
- name: Build project
run: |
cd build
make -f clang_makefile all
CC=clang CXX=clang++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
- name: Run tests
run: |
cd build
./fakeit_tests.exe
build/tests/FakeIt_tests
clang-ubuntu-18-04:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Build project
run: |
cd build
make -f clang_makefile all
CC=clang CXX=clang++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
- name: Run tests
run: |
cd build
./fakeit_tests.exe
build/tests/FakeIt_tests
25 changes: 11 additions & 14 deletions .github/workflows/ci_linux_gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,41 @@ jobs:
- uses: actions/checkout@v2
- name: Build project
run: |
cd build
make coverage
CC=gcc CXX=g++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON
cmake --build build -j
- name: Run tests
run: |
cd build
./fakeit_tests.exe
build/tests/FakeIt_tests
- name: Generate report
run: |
cd build
cd build/tests/CMakeFiles/FakeIt_tests.dir
gcov *.o
lcov --directory . -c -o report.info
lcov --remove report.info '/usr/*' '*/tests/*' -o report_filtered.info
- name: Upload report
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build/report_filtered.info
path-to-lcov: ./build/tests/CMakeFiles/FakeIt_tests.dir/report_filtered.info
gcc-ubuntu-20-04:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Build project
run: |
cd build
make all
CC=gcc CXX=g++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
- name: Run tests
run: |
cd build
./fakeit_tests.exe
build/tests/FakeIt_tests
gcc-ubuntu-18-04:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Build project
run: |
cd build
make all
CC=gcc CXX=g++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
- name: Run tests
run: |
cd build
./fakeit_tests.exe
build/tests/FakeIt_tests
33 changes: 33 additions & 0 deletions .github/workflows/ci_windows_msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI Windows/MSVC

on:
push:
pull_request:

defaults:
run:
shell: bash

jobs:
msvc-windows-2022:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- name: Build project
run: |
cmake -S . -B build -G "Visual Studio 17 2022"
cmake --build build --config Debug -j
- name: Run tests
run: |
echo "Not yet because bugged but it needs to be fixed."
msvc-windows-2019:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Build project
run: |
cmake -S . -B build -G "Visual Studio 16 2019"
cmake --build build --config Debug -j
- name: Run tests
run: |
echo "Not yet because bugged but it needs to be fixed."
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tests/x64/

# CLion files
.idea/
cmake-build-*/

# bii
bii/
Expand Down
75 changes: 17 additions & 58 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,18 @@
IF(BIICODE)
ADD_BII_TARGETS()
ENDIF()
# ARCH_INDEPENDENT option at write_basic_package_version_file requires 3.14 version of CMake.
cmake_minimum_required(VERSION 3.14)

#LIST(APPEND BII_LIB_SRC tests/argument_matching_tests.cpp)
###############################################################################
# HELP #
###############################################################################
#
# This CMakeLists.txt file helps defining your block builds
# To learn more visit http://docs.biicode.com/c++.html
#
# To include published cmake scripts:
# 1. INCLUDE(user/block/myrecipe) # include myrecipe.cmake from remote user/block
# 2. Remember to execute bii find
# Example:
# INCLUDE(biicode/cmake/tools) # Include tools.cmake file from cmake block from "biicode" user
# ACTIVATE_CPP11(INTERFACE ${BII_BLOCK_TARGET})
#
# Useful variables:
# To be modified BEFORE the call to ADD_BII_TARGETS()
# ${BII_LIB_SRC} File list to create the library
#
# To be modified AFTER the call to ADD_BII_TARGETS()
# ${BII_BLOCK_TARGET} Interface (no files) target for convenient configuration of all
# targets in this block, as the rest of targets always depend on it
# has name in the form "user_block_interface"
# ${BII_LIB_TARGET} Target library name, usually in the form "user_block". May not exist
# if BII_LIB_SRC is empty
# ${BII_BLOCK_TARGETS} List of all targets defined in this block
# ${BII_BLOCK_EXES} List of executables targets defined in this block
# ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use
# directly the name of the executable target (e.g. user_block_main)
#
# > EXAMPLE: Add include directories to all targets of this block
#
# TARGET_INCLUDE_DIRECTORIES(${BII_BLOCK_TARGET} INTERFACE myincludedir)
#
# > EXAMPLE: Link with pthread:
#
# TARGET_LINK_LIBRARIES(${BII_BLOCK_TARGET} INTERFACE pthread)
# or link against library:
# TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} PUBLIC pthread)
#
# NOTE: This can be also done adding pthread to ${BII_LIB_DEPS}
# BEFORE calling ADD_BIICODE_TARGETS()
#
# > EXAMPLE: how to activate C++11
#
# IF(APPLE)
# TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11 -stdlib=libc++")
# ELSEIF (WIN32 OR UNIX)
# TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11")
# ENDIF(APPLE)
#
# > EXAMPLE: Set properties to target
#
# SET_TARGET_PROPERTIES(${BII_BLOCK_TARGET} PROPERTIES COMPILE_DEFINITIONS "IOV_MAX=255")
#
project(FakeIt VERSION 2.3.2 LANGUAGES CXX)

option(ENABLE_COVERAGE "Enable coverage reporting for gcc/clang." OFF)

# Directory containing main targets of FakeIt.
add_subdirectory(include)

# Directory containing config targets of FakeIt.
add_subdirectory(config)

# Directory containing test targets of FakeIt.
add_subdirectory(tests)

# Directory containing single header targets of FakeIt.
add_subdirectory(single_header)
92 changes: 40 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ Linux / GCC: [![Build status Linux/GCC](https://github.com/eranpeer/FakeIt/actio

Linux / Clang: [![Build status Linux/Clang](https://github.com/eranpeer/FakeIt/actions/workflows/ci_linux_clang.yml/badge.svg)](https://github.com/eranpeer/FakeIt/actions/workflows/ci_linux_clang.yml)

MSC: [![Build status MSC](https://ci.appveyor.com/api/projects/status/sy2dk8se2yoxaqve)](https://ci.appveyor.com/project/eranpeer/fakeit)
MSVC: [![Build status Windows/MSVC](https://github.com/eranpeer/FakeIt/actions/workflows/ci_windows_msvc.yml/badge.svg)](https://github.com/eranpeer/FakeIt/actions/workflows/ci_windows_msvc.yml)

FakeIt is a simple mocking framework for C++. It supports GCC, Clang and MS Visual C++.

FakeIt is written in C++11 and can be used for testing both C++11 and C++ projects.

```cpp
struct SomeInterface {
virtual int foo(int) = 0;
virtual int bar(string) = 0;
virtual int foo(int) = 0;
virtual int bar(string) = 0;
};
```
```cpp
// Instantiate a mock object.
Mock<SomeInterface> mock;
Expand All @@ -32,10 +33,10 @@ SomeInterface &i = mock.get();
// Will print "1".
cout << i.foo(0);
```

Verify method invocation:

```
Verify method invocation
```cpp
Mock<SomeInterface> mock;

Expand Down Expand Up @@ -81,13 +82,14 @@ Depending on the unit testing framework you use, simply add one of the pre-packa
* <fakeit_folder>/single\_header/[gtest](https://github.com/google/googletest)
* <fakeit_folder>/single\_header/mstest
* <fakeit_folder>/single\_header/boost
* <fakeit_folder>/single\_header/[catch](https://github.com/philsquared/Catch) (Tested with Catch 2.0.1)
* <fakeit_folder>/single\_header/[catch](https://github.com/catchorg/Catch2) - (v2 and v3)
* <fakeit_folder>/single\_header/[tpunit](https://github.com/tpounds/tpunitpp)
* <fakeit_folder>/single\_header/[mettle](https://github.com/jimporter/mettle)
* <fakeit_folder>/single\_header/qtest
* <fakeit_folder>/single\_header/nunit - (See caveats in config/nunit/fakeit\_instance.hpp)
* <fakeit_folder>/single\_header/[cute](https://github.com/PeterSommerlad/CUTE)
* <fakeit_folder>/single\_header/standalone
* <fakeit_folder>/single\_header/[cute](https://github.com/PeterSommerlad/CUTE)
* <fakeit_folder>/single\_header/[doctest](https://github.com/doctest/doctest)
* <fakeit_folder>/single\_header/standalone - (if you don't use a unit testing framework)
For example, to use fakeit with **Google Test** simply add the *single_header/gtest* folder to the include path of your test project:
```
Expand All @@ -102,67 +104,53 @@ For example:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/gtest"
```
* To use fakeit with **MS Test** add the *include* folder and the *config/mstest* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/mstest"
```
* To use fakeit with **Boost Test** add the *include* folder and the *config/boost* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/boost"
```
* To use fakeit with **Catch** add the *include* folder and the *config/catch* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/catch"
```
* To use fakeit with **tpunit** add the *include* folder and the *config/tpunit* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/tpunit"
```
* To use fakeit with **Mettle** add the *include* folder and the *config/mettle* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/mettle"
```
* To use fakeit with **QTest** add the *include* folder and the *config/qtest* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/qtest"
```
* To use fakeit with **NUnit** in a managed Visual Studio C++/CLI project, add the standalone/nunit folder to your project include path. Note, it is useful to define your mocks
in `#pragma unmanaged` sections so that you can use lambda expressions.
* For every other unit test framework (or for using FakeIt without a unit test framework), just replace `gtest` by the name of the configuration:
* GoogleTest: `gtest`
* MSTest: `mstest`
* Boost.Test: `boost`
* Catch2: `catch`
* tpunit++: `tpunit`
* mettle: `mettle`
* Qt Test: `qtest`
* NUnit: `nunit`
* CUTE: `cute`
* doctest: `doctest`
* Without a unit test framework: `standalone`
* If you use FakeIt with **NUnit** in a managed Visual Studio C++/CLI project, note that it is useful to define your mocks in `#pragma unmanaged` sections so that you can use lambda expressions.
* To use fakeit with **CUTE** add the *include* folder and the *config/cute* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/cute"
```
* To use fakeit without any testing framework integration (**standalone**) add the *include* folder and the *config/standalone* folder to the include path of your test project:
```
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/standalone"
```
It is recommended to build and run the unit tests to make sure FakeIt fits your environment.
For GCC, it is recommended to build the test project with -O1 or -O0 flags. Some features of Fakeit may not work with stonger optimizations!!
For GCC, it is recommended to build the test project with -O1 or -O0 flags. Some features of FakeIt may not work with stronger optimizations!!
#### Building and Running the Unit Tests with GCC
```
cd build
make all
CC=gcc CXX=g++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
```
run the tests by typing
Run the tests by typing:
```
./fakeit_tests.exe
./build/tests/FakeIt_tests
```
#### Building and Running the Unit Tests with Clang
```
cd build
make -f clang_makefile all
CC=clang CXX=clang++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
```
run the tests by typing
Run the tests by typing:
```
./fakeit_tests.exe
./build/tests/FakeIt_tests
```
#### Building and Running the Unit Tests with Visual Studio
Open the tests/all_tests.vcxproj project file with Visual Studio. Build and run the project and check the test results.
```
cmake -S . -B build -G "Visual Studio 17 2022"
cmake --build build --config Debug -j
```
Run the tests by typing:
```
./build/tests/Debug/FakeIt_tests.exe
```
## Limitations
* Currently only GCC, Clang and MSC++ are supported.
Expand Down
10 changes: 0 additions & 10 deletions appveyor.yml

This file was deleted.

11 changes: 0 additions & 11 deletions biicode.conf

This file was deleted.

0 comments on commit 5b131db

Please sign in to comment.