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.
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
We have a project using C#, C++/Cli and some native C++ code. We use TeamCity for building and testing.
We run the tests using vstest.console (VS2012 test runner).
For managed code, dotCover (which is integrated into TeamCity) is used for code coverage. However, it doesn't work with native C++ code (which is to be expected).
How do I get code coverage results our unit tests for the native C++ parts into TeamCity? Ideally, the solution would be free.
We use Bullseye Coverage for C++ code coverage. We then use the provided covxml tool to convert the binary coverage files into an XML file, which we then read out a bunch of useful attributes for function and conditional coverage (e.g. fn_total, fn_cov, cd_total, cd_cov) and provide these to TeamCity via the statistics service messages using the predefined coverage keys.
It was a bit of work to set up, but I think TeamCity still has no support for any C++ coverage tool, so our solution still works well for us years later.
Edit: I've uploaded the XML parsing code for our in-house tool to a Gist.
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.
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
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?