Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C/C++ testing framework (like JUnit for java) [closed]

Tags:

c++

c

testing

Been hitting my head on the wall before as I don't make any test classes while using c/c++ (but instead have a lot of print methods).

What is the most used method to perform testing in the c/c++ code? Java's JUnit has only left me with good memories while debugging things.

I know that using asserts in code with a defined debug header should work, but aren't there any better ways?

And since I have the intention to make test classes in the future, any useful tips are welcome.

like image 677
Milan Avatar asked Jul 01 '09 04:07

Milan


People also ask

Does C have unit testing?

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.

Is JUnit still used?

Yes, JUnit is an open-source project, maintained by many active developers.

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.

What is JUnit testing framework?

JUnit is a Java unit testing framework that's one of the best test methods for regression testing. An open-source framework, it is used to write and run repeatable automated tests. As with anything else, the JUnit testing framework has evolved over time.


2 Answers

We use Google Test and it's companion Google Mock. Works wonderfully and supports JUnit style XML output for easy integration with CruiseControl, etc. It's also fully cross platform, and from my research a few months ago, GMock was the ONLY fully cross platform object mocking framework for C++.

like image 58
Grant Limberg Avatar answered Oct 16 '22 01:10

Grant Limberg


We use boost.Test. There is also cppunit.

like image 27
chrish Avatar answered Oct 15 '22 23:10

chrish