Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit-like test framework for C++ in Eclipse CDT [closed]

I'm looking for a test framework for C++ in Eclipse CDT. Ideally it should have similar functionalities to those offered by JUnit.

I tried CUTE. It is good but I cannot seem to create unit tests within the project I'm currently working on. Neither can I create a separate unit test project to test my current project, because my current project is a C++ hello world application, but CUTE only allows testing project for a C++ library.

Any idea of other test frameworks I may count on, and is there any tutorial available? Thanks.

like image 439
Shuo Avatar asked Nov 06 '11 21:11

Shuo


People also ask

What is the best unit test framework for 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 CDT in Eclipse?

The CDT is Eclipse's C/C++ Development Tooling project. It is an industrial-strength C/C++ IDE that also serves as a platform for others to provide value-added tooling for C/C++ developers.

How do I change test runner in eclipse?

All tests should be run with jUnit3, if i run a non-configured Test, it tries to use the default-TestRunner (jUnit4). So, i have to go into the run/debug configuration, change the TestRunner to "jUnit3" and run it again. On EVERY Test.


2 Answers

I use Google Test Framework and Google Mock Framework with Eclipse CDT C/C++ Tests Runner plugin. This plugin also works with qt tests and boost tests. Look and feel like junit in java eclipse :)

Google test framework is very well described here: http://code.google.com/p/googletest/

Eclipse CDT C/C++ Tests Runner plugin: https://github.com/xgsa/cdt-tests-runner/wiki/Tutorial

You can use it by creating new project for test or directly in current project by creating separate build and run action for test runner. I have 2 folders in my project, Source and Tests, Tests folder is exclude from normal build, so I can run test and build application using one project.

like image 165
dikamilo Avatar answered Sep 22 '22 16:09

dikamilo


The problem you describe with CUTE is that you need to find a way to split up your application so you move the functionality you want to test to a library. Every test framework will put this requirement on your project structure.

Try GoogleTest or Boost.Test.

GoogleTest does not have a plugin for Eclipse.

see this issue: http://code.google.com/p/googletest/issues/detail?id=40

Cppunit is abandonware in the sense that it is not actively being maintained anymore.

like image 23
Eddy Pronk Avatar answered Sep 24 '22 16:09

Eddy Pronk