Is there any unit testing framework for C like JUnit and Nunit for java and .NET? Or how do we test a piece of code written in C for different scenarios?
Thanks in advance......
The most scalable way to write unit tests in C is using a unit testing framework, such as: CppUTest. Unity. Google Test.
A Unit Testing Framework for CCUnit is a lightweight system for writing, administering, and running unit tests in C. It provides C programmers a basic testing functionality with a flexible variety of user interfaces.
Advertisements. Unit testing is a software testing method by which individual units of source code, such as functions, methods, and class are tested to determine whether they are fit for use. Intuitively, one can view a unit as the smallest testable part of an application.
GoogleTest requires a codebase and compiler compliant with the C++11 standard or newer.
I have worked some with Check and its very easy to setup. Its used by some big active projects like GStreamer. Here is a simple example of fail if line:
fail_if (0 == get_element_position(spot), "Position should not be 0");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With