Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automated C unit testing

I have a C library compiled with MinGW, Eclipse C project. Library consists of many modules, each module can be tested.

What is the best way (using MACROS or something) how to write tests for this library, compile it a run it in Eclipse/CDT IDE?

EDIT: I've seen that some people use

#ifdef TEST

int main(void)
{
   ...TEST LOGIC...
}
#endif

but don't know how to plug it into Eclipse.

like image 275
Cartesius00 Avatar asked Jul 22 '11 19:07

Cartesius00


People also ask

What is automated unit testing?

Automated unit testing is a method of testing software. Units (small sections) of the code are rigorously checked to ensure they work correctly. A separate program can be written specifically to test the unit, using every reasonable piece of data the code might encounter in real-world use.

Can unit testing of code be automated?

Unit testing can be done manually but is usually automated. Unit testing is a part of the test-driven development (TDD) methodology that requires developers to first write failing unit tests. Then they write code in order to change the application until the test passes.

What can be used for unit testing in C?

The most scalable way to write unit tests in C is using a unit testing framework, such as: CppUTest. Unity. Google Test.

Is Jtest a unit testing tool?

Jtest is an automated Java software testing and static analysis product developed by Parasoft. The product includes technology for Data-flow analysis, Unit test-case generation and execution, static analysis, and more.


1 Answers

I'd suggest to use CuTest with a Makefile.

like image 90
brandizzi Avatar answered Sep 22 '22 02:09

brandizzi