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.
Related
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.
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).
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.
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?
Is there a unit testing framework for Microsoft Visual C++ 6.0?
I'm not a C++ programmer, but I think CppUnit does the trick. I'm sure there are others.
You can read this article for list of all C++ unit testing frameworks, and check which one is working with VS6.0
There's a VC6 port of Phil Nash' Catch test framework.
Catch is easy to start with as it is packaged up as a single header and has no external dependencies other than the C++ standard library.
Test cases are written as self-registering functions or methods, optionally divided into sections. Catch needs only one core assertion macro for comparisons, using standard C operators for the comparison - yet decomposing the full expression and logging both lhs and rhs values.
CppUnit requires more work than necessary, particularly the work it takes to create a new test case. The original author, Michael Feathers, published a simplified framework which has been used as the basis for others. I've used UnitTest++, and am very interested in googletest. Either one will let you create a new test case without having to declare it and manually add it to a suite; the frameworks do that for you.