I've written some ObjC unit tests for use with the OCUnit support in Xcode. Now I would like to do the same for some of the C++ code I'm about to write (a separate static library).
Is there any support for e.g. CppUnit (or some other C++ test framework) in Xcode? When I write support, I mean I want to run the tests and display the results in the Xcode GUI.
Have you looked at Google C++ Testing Framework? That one should be pretty portable.
Related
I've recently switched to an Ubuntu os where I'm working on an important c++ project. I am using eclipse as an IDE and I was wandering what is the best way to do unit testing considering I've never done any unit testing.
Links for tutorials would be most appreciated.
I used google test for unit testing my project which is C++ based. It is easy to set up and use. Please check the below link.
http://www.codeproject.com/Articles/811934/Cplusplus-unit-test-start-guide-how-to-set-up-Goog
I am using OCTest for Objective-C code. Does OCTest support C++? How do I go about writing tests for C++ classes?
I come from the world of Java and JUnit. I made a demonstration of Hudson and all what I achieve there with JUnit among other things. I would like to do the same with C++ code on an embedded device but can't find where to start.
THe project is compiled with iccarm.exe (IAR compiler) Right now the output is converted into an image file using romutil.exe to be flashed to the ARM9 board.
I tried to follow this tutorial: http://netbeans.org/kb/docs/cnd/c-unit-test.html but I'm having issues trying to figure out how to port it to my case.
Can I run unit tests on the C++ code outside of the device? (i.e. for doing it with Hudson to gather reports and so on)
Can I turn the output into an exe? (looks like Netbeans expects it to be)
What's the most appropriate unit framework for my case? (CppUnit, CUnit, etc)
Any help/direction is more than welcome.
1) You could build a cross-compiler, and then instead of using iccarm.exe, use the cross compiler. There are lots of tutorials on the net how to build a cross compiler using gcc. Then instead of building for the target (using cross compiler) build for your host using normal compiler.
3) Whatever you like. cppunit, google unit tests, etc
Does any one know if I can test native code in VS Test 2010?
you can find here an interesting way to do it.
Apparently not according to the docs here.
You cannot have test projects with
unit tests that use unmanaged C++.
This is confirmed by MSFT here.
There was another question here on the stack that I can't find, but it linked me off to
How Do I: Create and Run Unit Tests in Visual C++?
This shows that you can unit test native code including C++ but to do so you would still write the unit tests in managed code.
I have not tried this in person, and one thing I noticed was the demo used the COM interface to test the C++ native code, so have no specific experience of using C++ classes more directly in the unit test.
we have a huge codebase with about 1000k lines of native/unmanaged legacy c++ - code and we are going to provide the code with unit tests and MSTest would fit perfectly in our current development environment (TFS, VS 2010, ...). I know that MSTest is orginally meant to test managed code but its also possible to write unit tests for unmanaged sc.
Are there any (later) drawbacks on the usage of MSTest for unmanaged code? Does anyone have any experience on this?
The second opinion would be using Google.Test, but I would have to write a Visual Studio add-in to integrate the gtest framework in our environment.
Thanks in advance!
I would not recommend MSTest for managed testing. See here for my experiences. However if you do insist I would say a really good way to test you legacy code would be use PInvoke interop to your c++ code.
I would recommend googletest anyway. I think they will also gladly accept your VS integration and include it in the next release, provided the patch has reasonable quality.
Oh, and you can use another great Google project then, gmock.
I use the Boost.Test framework to test my C++ code in Visual Studio without any issues. You need to create a test project (a console-mode EXE) that contains your tests which your main project can depend on. Using the Visual Studio 'post build' step you can run the tests automatically.