Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/islamhaqq/sahltestingframework
Unit Testing Framework (Mocking Library Included)
https://github.com/islamhaqq/sahltestingframework
automation automation-framework google-test mocking mocking-library tdd testing unit-testing
Last synced: 5 days ago
JSON representation
Unit Testing Framework (Mocking Library Included)
- Host: GitHub
- URL: https://github.com/islamhaqq/sahltestingframework
- Owner: islamhaqq
- Created: 2023-04-29T02:19:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-03T15:16:38.000Z (9 months ago)
- Last Synced: 2024-09-13T15:42:43.197Z (2 months ago)
- Topics: automation, automation-framework, google-test, mocking, mocking-library, tdd, testing, unit-testing
- Language: C++
- Homepage:
- Size: 75.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TestingFramework
A unit testing framework for C++ that includes:
* Test running
* Test specification
* Expectations
* MockingThe heavy usage of macros takes inspiration from Google Test. Although the implementation is different, the interface for creating tests and mocking has similaries to gtest and gmock.
## Example Usage
You can take a look at the automation tests under the `/Tests` directory for the most up-to-date self-documentation. But here are some test usages if you don't want to do that:```cpp
class SomeInterface
{
public:
virtual int SomeMethod() = 0;
virtual int SomeOtherMethod() = 0;
virtual bool SomeBoolMethod() = 0;
virtual std::string SomeStringMethod() = 0;
};class MockImplementation : public SomeInterface
{
MOCK_METHOD(int, SomeMethod)
MOCK_METHOD(int, SomeOtherMethod)
MOCK_METHOD(bool, SomeBoolMethod)
MOCK_METHOD(std::string, SomeStringMethod)
};S_TEST(MyTestSuite, MyTest)
{
MockImplementation mockImplementation;
ON_CALL(mockImplementation, SomeMethod).WillByDefault([]() { return 5; });
S_EXPECT_EQ(mockImplementation.SomeMethod(), 5);ON_CALL(mockImplementation, SomeOtherMethod).WillByDefault([]() { return 6; });
S_EXPECT_EQ(mockImplementation.SomeOtherMethod(), 6);ON_CALL(mockImplementation, SomeBoolMethod).WillByDefault([]() { return true; });
S_EXPECT_TRUE(mockImplementation.SomeBoolMethod());
ON_CALL(mockImplementation, SomeBoolMethod).WillByDefault([]() { return false; });
S_EXPECT_FALSE(mockImplementation.SomeBoolMethod());ON_CALL(mockImplementation, SomeStringMethod).WillByDefault([]() { return "Hello"; });
S_EXPECT_STREQ(mockImplementation.SomeStringMethod().c_str(), "Hello");
}
```# Installation
You will need to following dependencies:
* [CMake](https://cmake.org/download/)
* [GCC/G++ (Linux)](https://gcc.gnu.org/install/)
* [MSVC (Windows)](https://visualstudio.microsoft.com/downloads/)
* [xlib w/ XRandR and XTest (Linux)](https://www.x.org/wiki/)## Linux
```bash
sudo apt-get install libxrandr-dev
sudo apt-get install libxtst-devcd SahlTestingFramework
cmake -B build
cmake --build build# Run tests to make sure everything is working
cd build
ctest --extra-verbose
```