Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azure/ctest
A simple portable C test runner
https://github.com/azure/ctest
c test-runner testing testing-tools tests
Last synced: about 1 month ago
JSON representation
A simple portable C test runner
- Host: GitHub
- URL: https://github.com/azure/ctest
- Owner: Azure
- License: other
- Created: 2016-05-05T02:23:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-26T18:59:23.000Z (about 1 month ago)
- Last Synced: 2024-09-30T16:11:23.538Z (about 1 month ago)
- Topics: c, test-runner, testing, testing-tools, tests
- Language: C
- Size: 450 KB
- Stars: 19
- Watchers: 52
- Forks: 12
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
# ctest
ctest is a simple portable C test runner.
## Setup
1. Clone **ctest** by:
```
git clone https://github.com/Azure/ctest
```2. Create a folder called *cmake* (or any name of your choice).
3. Switch to the *cmake* folder and run
```
cmake ..
```### Build
Switch to the *cmake* folder and run:
```
cmake --build .
```### Installation and Use
Optionally, you may choose to install ctest on your machine:1. Switch to the *cmake* folder and run
```
cmake --build . --target install
```
orLinux:
```
sudo make install
```Windows:
```
msbuild /m INSTALL.vcxproj
```2. Use it in your project (if installed)
```
find_package(ctest REQUIRED CONFIG)
target_link_library(yourlib ctest)
```### Building the tests
In order to build the tests use the *run_unittests* cmake option:
```
cmake .. -Drun_unittests:bool=ON
```## Example
```c
#include "ctest.h"
#include "SomeUnitUnderTest.h"CTEST_BEGIN_TEST_SUITE(SimpleTestSuiteOneTest)
CTEST_FUNCTION(Test1)
{
// arrange// act
int x = SomeFunction();// assert
CTEST_ASSERT_ARE_EQUAL(int, 42, x);
}CTEST_END_TEST_SUITE(SimpleTestSuiteOneTest)
```