If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Unit testing

Today you can test native applications using the unit testing framework in VSTS, so long you write your tests as managed code. You'll get the full experience with that including the colorization in the editor. (The colorization tells you what code you are covering with your unit tests and what you are not.)

Of course, the giant caveat here is that you have to write your tests in some kind of managed code. This is only a viable approach if your project is componentized in some way. For example if you are using COM I suggest writing your unit tests in managed code and using COM interop which is quite nice. If you have dlls I suggest C++/CIL. It's also a pretty good experience. Unforunately if you have static .libs or components that are part of an executable it's much harder to test those today. You can make your test project C++/CIL and actually include the source files in there but I will admit it's not a good experience.

This ties into your deeper question which is, "when will there be first class native unit testing?" We're very aware that the unit testing experience for native code isn't the best and we want to improve it. For Dev10, unforunately, we won't be improving this situation any. We're definitely taking a look at this for the next release, though. We know it's a frustrating situation.

If you want to know more about how to use the unit testing framework today to test your native code I'll be happy to give you pointers.

Re: Unit testing

Re: Unit testing

Originally Posted by linxu

Today you can test native applications using the unit testing framework in VSTS, so long you write your tests as managed code. You'll get the full experience with that including the colorization in the editor. (The colorization tells you what code you are covering with your unit tests and what you are not.)

Could you go into a bit more detail (or post a link to same info) on how to get the unit test covered native code to be colorized in the editor? I have done a unit test in C++/CLI to test a C++ native code class in a DLL and have been successful in getting it to execute correctly. (BTW, I also did the same class unit test in CppUnit and Boost::Test for comparison). However, I never did see any code coverage indication for the native code. Did I simply forget an option somewhere or missing something simple? Thanks.

Getting code coverage indication in the native code automatically would be a big plus for the MS Unit Test approach compared to CppUnit or Boost::Test and would compensate for some of the negatives for needing to write the test in managed code to begin with.

Re: Unit testing

Re-reviewing Visual Studio help, I'm guessing I need one of the Visual Studio Test editions to get code coverage as I do not have a Code Coverage selection in my test run configuration dialog as per VS Help. I think that was the conclusion I came to the 1st time I looked into this but your post gave me new hope.

So is this the case: that I need one of the Test editions to get code coverage? I am only using the Professional edition.

Re: Unit testing

Originally Posted by wlater

Could you go into a bit more detail (or post a link to same info) on how to get the unit test covered native code to be colorized in the editor? I have done a unit test in C++/CLI to test a C++ native code class in a DLL and have been successful in getting it to execute correctly. (BTW, I also did the same class unit test in CppUnit and Boost::Test for comparison). However, I never did see any code coverage indication for the native code. Did I simply forget an option somewhere or missing something simple? Thanks.

Getting code coverage indication in the native code automatically would be a big plus for the MS Unit Test approach compared to CppUnit or Boost::Test and would compensate for some of the negatives for needing to write the test in managed code to begin with.

Hi,

Are you saying that you have unit tests written in C++/CLI for code that is written in Native C++ without CLR support? If yes, can you provide me some points how to do it?

Re: Unit testing

Hi oliver_mk,

As a first step, you might want to try modifying your C++/CLI unit test project to use /clr as opposed to /clr:safe. The latter is the default, but the former option will allow you to interact with native code.

Re: Unit testing

Are you saying that you have unit tests written in C++/CLI for code that is written in Native C++ without CLR support? If yes, can you provide me some points how to do it?

Yes, that's correct. I have a native C++ class compiled within a fully native DLL. I then have unit tests written in C++/CLI with objects of the native class. There's really not much special to tell in terms of how to do it. I simply used the Wizard to create the unit test outlines and then added in my specific tests. Biggest problem was that the particular native class I used made use of CString in its interface and C++/CLI won't work with that directly. So anytime I needed to deal with a CString (such as compare that it matched a known pattern), I had to convert it to a String using a String constructor. Little bit of extra overhead, but not too bad.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.