Is it OK to use MS Fakes shims with NSubstitute mocks? - unit-testing

We are using NSubstitute to mock external objects for our unit tests. However many legacy classes are not called via interfaces and can't be easily replaced with mocks.
I've considered to use Microsoft Fakes, but according to the answer for the question "Mock framework vs MS Fakes frameworks"
" if you're already using a more full-featured mocking framework, you
might feel like there are some important pieces missing from Fakes
stubs."
Would it be possible to use MS Fakes shims with NSubstitute mocks in the same tests?
Should we expect any compatibility problems?

Yes. I've been using Shims together with NSubstitute for several months. It work fine both locally and on build server. The only trouble is Resharper test runner does not work with Shims, so we have to use VisualStudio's test runner instead.

Yes, you should be able to use Shims with mocking frameworks.

Related

Does Microsoft fakes framework support c++/unmanaged code

We are developing unit tests for already existing code in c++. In the recent TechEd heard about Microsoft fakes framework for unit test isolation. But the TechEd video does not show that it is supported for c++ or not. No such this is said on msdn as well. But all examples on msdn is for c# and VB.
Does anyone know if it is supported or not. If not what framework would you recommend for already existing c++ code which is not developed with unit testing in mind.
So, finally microsoft responded to the question and the conclusion is, fakes does not support c++/unmanaged code.
https://connect.microsoft.com/VisualStudio/feedback/details/890349/does-microsoft-fakes-framework-support-c-unmanaged-code

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.

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.

Code Coverage when using NUnit to test unmanaged 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?

Categories