Code Coverage when using NUnit to test unmanaged C++ - c++

My team is currently using CppUnit for all our unmanaged C++ unit tests but I'm toying with the idea of transitioning to NUnit through either GenTestAsm (pure C#) or C++/CLI. Either way, what consequences would I face on the Code Coverage front with either of these approaches?
We currently use PureCoverage to instrument our unmanaged unit test executables for collecting coverage data. Would we still be able to do this or is there another tool? Or would we lose code coverage visibility all together?

Related

How to set data-driven tests for C++ tests using MSTest?

I am trying to use microsoft unit tests for native code, however after writing basic tests i have run into a problem: i could not find how to make test methods with parameters.
When searching for the topics, i found some ways to add such methods, namely to write data-driven tests (for example, http://msdn.microsoft.com/en-us/library/ms182527.aspx). However i am at loss as to how to use it together with native C++ tests.
As far as i could determine, no TEST_METHOD macro exists for functions with parameters, no macro for 'DataSource' attribute exists etcetera.
Is there an example of setting up data-driven test of native c++ code using MsTest?
Data Driven tests are not supported in Native C++ MSTest Framework.

Cross platform automated testing - Is there a way?

I have a small library that is ported to different platforms (win, os x, ios, android) that I am using in some small personal utilities and I am starting to look into testing more thoroughly.
Right now, I am using NUnit to test the windows version, with test cases written in c#. The setup just basically loads the dll and the test cases make various calls to the library. I want to duplicate this testing on the other platforms. I know there are other xUnit type frameworks to accomplish this on the other platforms, JUnit etc., but I would rather not have to rewrite the test cases for each platform.
Is there a recommended way to have one set of test cases and just point them to one of the libraries to run against that platform?
I still consider myself a novice programmer, so apologies if it's not possible and the question is naive.
Thanks
Due to the nature of unit testing(testing individual procedures or functions rather than overall program functionality as in blackbox testing ), and different languages supports different language specific features, there cannot exist a universal unit testing framework that supports all programming languages (in your case, Java, C#, Objective-C ). That's why we have xUnit framework for different languages.
Even if someone creates such framework, it would not be possible to properly test functions that uses language specific features.

Automated Unit Testing of C++

Is there any way to generate automated unit test cases for c++ code written using VS2005. I do some basic R&D and found that there is a support for automated testing in VS2005 but its only for Managed Code, so i am looking for something specific to:
"Automatic generation of Test cases of Native C++ Code"
It doesn't matter whether its a plug-in that works with VS2005 or any standalone application. But it is preferred to have some plug-in sort of solution.
I can't tell if you are asking about a unit testing framework (if yes, try cppUnit), or if you really want tests code-generated. If the latter, I imagine the answer is no. Usually a capability like that is linked to reflection and/or built-in design-by-contract capabilities (e.g Eiffel or C# with .net 4.0).

Can I create automatic Unit Tests for C++

When I create a program using C# and VS2008 , then I can create a test case just by Rightclicking on the method. But I am not sure If I can create the tests in the same way if it is a C++ project.
Due to the lack of reflection in C++, you propably wont be able to have these kind of unit tests, VS provides.
I'm pretty sure you can't. You can create a C++/CLI test project and tests manually though. The IDE will create a C++/CLI test class with stubs etc. for you.
I agree with the answers above, just adding...or use the boost library:
http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/index.html
You might want to take a look at CppUnit or googletest for unit testing with C++. You won't have the IDE generation of test cases, but there are unit testing frameworks out there.

It is possible/productive enough to TDD in C++ projects?

I want to know if anyone of you guys use TDD in your c++ projects and how it performs compared to managed languages like C# and Java.
And what frameworks you guys are using to automate tests on c++ projects?
Two useful C++ test frameworks that don't seem to have been mentioned yet are Boost test and Google Test.
Test Driven Development is possible in any language. You need the right testing tools and methodologies for the language, and may possibly need a custom testing infrastructure for your project.
I have found CppUnit (at least 1.x) to be a very poor framework -- it seems to use Java/C# idioms in a C++ language and does not have support for STL constructs.
If you want a good example of Test Driven Development (in C), look at the Wine project -- http://test.winehq.org/data/ shows their test results across the different versions of Windows, Wine and the different commits into the Wine repository. They have their own custom test infrastructure.
I recently moved from a C# project that was developed using TDD to a project that is using C++. I was dreading it quite a bit, but I find that doing C++ with TDD is a lot more enjoyable and the code is more robust than I remember from past (non-TDD) experiences with C++.
We are using Google Test. It is not as easy to use as NUnit/MbUnit, but it seems to work pretty well. There is also a Google mocking framework http://code.google.com/p/googlemock , but I have not been using that yet.