UnitTesting for mixed C++/Cli projects - c++

Which UnitTest framework should I use to test mixed C++ code (native and C++/CLI)? Any HowTo's or Tutorials?
Thx

You can use NUnit to test both very easily. If you write the tests in C++/CLI you will be able to test the native code too.
See here for a related discussion.

Related

unit test framework + code coverage tool for C++

We should select tool for our C++ code.
Is there a same tool or the tools of the same company for unit test framework
and code coverage tests?
Our aim if the both tool can work compatibly.
Sorry for my english
Thank you very much
For code coverage you can use the lcov tool and as Unit test Framework you can take a look at the Boost library
I used both CxxTest and GoogleTest and both do the job, with a main difference that the former is using pre-build script to generate the test driver code and the later uses static registration of tests which the driver later uses.
For coverage under Windows Bullseye Cover is a great product.

Testing with Visual Studio Test 2010

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.

MSTest for huge legacy codebase

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.

What advantages/disadvantages do MSTest and NUnit have compared to each other?

Since Microsoft created MSTest, I've been using it for unit testing. I never really used NUnit, and I just didn't like the need to have yet another tool installed on my dev box. I've only used the basic features of MSTest so far, and they have satisfied my needs, and I don't really know anything about NUnit.
Could someone list out some of the disadvantages and advantages of using MSTest and NUnit compared to each other?
Here is a nice blog which lists out some differences between MSTest and NUnit http://blogs.msdn.com/nnaderi/archive/2007/02/01/mstest-vs-nunit-frameworks.aspx
And this link here compares even more unit testing frameworks http://www.codeplex.com/xunit/Wiki/View.aspx?title=Comparisons
cheers
Here's a more recent review of Nunit, Mstest for Visual Studio:
http://www.barebonescoder.com/2010/06/mstest-vs-nunit-with-visual-studio-2010-tdd/
For .net core:
NUnit was not fully compatible with .NET Core 2 at the time
https://dev.to/hatsrumandcode/net-core-2-why-xunit-and-not-nunit-or-mstest--aei
Some new features in xUnit:
https://dev.to/franndotexe/mstest-v2---new-old-kid-on-the-block

Setting up Mobile JUnit tests to run under JUnit

I'm using Mobile JUnit, released by Sony Ericsson for unit testing for my J2ME project. I read in the documentation that one can run the tests under regular junit with the help of a few wrapper classes. The documentation, in fact, recommends that you do this if you want to generate reports for CI builds, etc. which is exactly what I want.
Unfortunately, the documentation is a little terse on how to do this. Has anyone had any luck with this aspect of Mobile JUnit?
What I did (and I'm not saying this is necessarily a good idea in general, but it worked in my specific case) was to separate the the code base into a library and the UI. The library didn't include an J2ME specific stuff in it and it didn't include anything that J2SE had the J2ME didn't. As a result, you could check it out in NetBeans as a J2SE project and it would compile. Then I wrote JUnit tests in the J2SE context. This doesn't help test the UI, but it made it very easy to test the library.
It sounds like you found a more complete solution that tests both. Can you elaborate on what microemulator you used?