All Projects → ollelogdahl → Ihct

ollelogdahl / Ihct

Licence: mit
'I Hate C Testing': A minimal testing framework for C.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Ihct

Cucable Plugin
Maven plugin that simplifies running Cucumber Scenarios in parallel.
Stars: ✭ 110 (-28.57%)
Mutual labels:  test-automation
Gabbi
Declarative HTTP Testing for Python and anything else
Stars: ✭ 132 (-14.29%)
Mutual labels:  test-automation
Ztest
自动化测试报告
Stars: ✭ 143 (-7.14%)
Mutual labels:  test-automation
Ltp
Linux Test Project http://linux-test-project.github.io/
Stars: ✭ 1,654 (+974.03%)
Mutual labels:  test-automation
Zebrunner
Zebrunner is a Test Automation Management Tool
Stars: ✭ 131 (-14.94%)
Mutual labels:  test-automation
Penetration
渗透 超全面的渗透资料💯 包含:0day,xss,sql注入,提权……
Stars: ✭ 1,706 (+1007.79%)
Mutual labels:  test-automation
Selenium Cucumber Js
Browser automation framework written in pure JavaScript using official selenium-webdriver and cucumber-js
Stars: ✭ 108 (-29.87%)
Mutual labels:  test-automation
Stryker Js
Mutation testing for JavaScript and friends
Stars: ✭ 2,043 (+1226.62%)
Mutual labels:  test-automation
Unium
Automation for Unity games
Stars: ✭ 132 (-14.29%)
Mutual labels:  test-automation
Strest
⚡️ CI-ready tests for REST APIs configured in YAML
Stars: ✭ 1,746 (+1033.77%)
Mutual labels:  test-automation
Stryker4s
Mutation testing for Scala. Work in progress...
Stars: ✭ 118 (-23.38%)
Mutual labels:  test-automation
Mountebank
Over the wire test doubles
Stars: ✭ 1,678 (+989.61%)
Mutual labels:  test-automation
Selenium extensions
Tools that will make writing tests, bots and scrapers using Selenium much easier
Stars: ✭ 140 (-9.09%)
Mutual labels:  test-automation
Arquillian Cube
Control (docker, kubernetes, openshift) containers in your tests with ease!
Stars: ✭ 110 (-28.57%)
Mutual labels:  test-automation
Genieparser
sub-component of Genie that parse the device output into structured datastructure
Stars: ✭ 146 (-5.19%)
Mutual labels:  test-automation
Atx
Smart phone automation tool. Support iOS, Android, WebApp and game.
Stars: ✭ 1,489 (+866.88%)
Mutual labels:  test-automation
Kotlin Faker
Generate realistically looking fake data such as names, addresses, banking details, and many more, that can be used for testing and data anonymization purposes.
Stars: ✭ 136 (-11.69%)
Mutual labels:  test-automation
Swagger meqa
Auto generate and run tests using swagger/OpenAPI spec, no coding needed
Stars: ✭ 151 (-1.95%)
Mutual labels:  test-automation
Stb Tester
Automated Testing for Set-Top Boxes and Smart TVs
Stars: ✭ 148 (-3.9%)
Mutual labels:  test-automation
Zunit
A powerful testing framework for ZSH projects
Stars: ✭ 140 (-9.09%)
Mutual labels:  test-automation

ihct

'I Hate C Testing': a minimal testing framework for C

Olle Lögdahl, 13 December 2020

make docs licence issues sloc


ihct is a minimal C unit-testing framework. Intended for light unit testing, and focusing on development speed. Looking for more features, so please give any suggestions.

Installation & Usage

See documentation

To use this framework, simply include ihct.h in your project and link to the library. Everything else happens automatically. The following code should get you started.

#include <ihct.h>

IHCT_TEST(arithmetic_basic) {
    int a = 13;
    IHCT_ASSERT(a + 2 == 15);
    IHCT_ASSERT(a * 2 == 26);
}
IHCT_TEST(string_basic) {
    char *s1 = "abba";
    IHCT_ASSERT_STR(s1, "abba");
}

int main(int argc, char **argv) {
    return IHCT_RUN(argc, argv);
}

To fully install the library, run:

mkdir build
cd build
cmake .. && make -j4
sudo make install

See ex.c for an extended example. Note that tests are created as it's own executable, and therefore needs an entrypoint. The example ex.c can be compiled and executed by running:

mkdir build
cd build
cmake .. && make -j4
./example

Why?

I have for a long time been stuck at unit testing in plain C. Many modern solutions use C++ as a test environment for C, but I wanted something more lightweight, that i can quickly get up to speed with. I decided to write my own test framework with two things in mind: development speed and minimalism. To improve development speed, all test functions are automatically included into the runner, and the library interface is kept minimal. It requires no dependencies other than a POSIX compliant OS, and compiles on all GNU C99 POSIX compatible compilers. The library also implements some safety to tests, catching fatal signals and hung functions.


Features

  • Basic test units
  • Basic asserts
  • Automatic test loader
  • Catching fatal signals (SEGFAULTS etc.) in tests (no line number, but sets them as failed).
  • Catching hung tests (again, no line number).

Self tests can be run along with own tests by adding compiler flag -DIHCT_SELF_TEST. (This may be very redundant; just see it as more examples :-) )

all macros (IHCT_TEST, IHCT_ASSERT etc.) can be shortened to remove the IHCT prefix, by defining IHCT_SHORT before including the header file.

Compatability notes

  • Since it requires __attribute__((constructor)) it is not compilable with MSVC.
  • Since it uses pthreads and signals, it is POSIX (again, not sure it works with Windows).

Links

  • Repository
  • For reporting errors, visit Issue Tracker!
  • Related Projects:
    • cheat by Guillermo "Tordek" Freschi and Sampsa "Tuplanolla" Kiiskinen

Licensing

This project, and all code it contains, is licensed under the MIT License and can be read here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].