I cannot create unit test for my application?

I found an article here,
http://msdn2.microsoft.com/en-us/library/ms243171(VS.80).aspx

My application is written by VC6 originally and I already migrated my projects to VS 2005. After migration, the project setting do not have /clr. That is, I did not enable Common Language Runtime Support. Is that mean, I can not create unit test program for my application

Is that mean, there are some limitation when using the unit test features in VS 2005

The article mentioned that :

Unmanaged. If your production code is unmanaged, it needs to be callable from a static library, an .obj file, or a DLL entry point. Class methods that are embedded inside an executable file or a DLL will not work because unmanaged Visual C++ does not offer the runtime discovery mechanism, reflection. Therefore, only the traditional native binding mechanisms will work.

So, I have more questions :

  • if I want to test my application, my application need to be written as production code, right
  • Unmanaged code, what is that mean

Thank you very much for your kindly help.



Answer this question

I cannot create unit test for my application?

  • Deicide

    I will try to answer to some of your questions:

    You can create a test project with unit tests that calls APIs in your native VC code but that has to be done using standard methods that used to call native APIs from managed code. Example would be to use DllImport attribute for function entry point in native code.

    Your second question is very general. So before I address your second question I would like to know what limitation do you see and we can try to see whether we can provide you with solution and give more proper answer. If it is regards to testing native code than as you can see in the link, you can write unit tests against native and managed codes.

    You can basically consider your existing VC project as production code.

    If your VC project is not build with /clr option that is considered as unmanaged code.

    Thanks,

    Bata Chadraa

    VSTT


  • Baloodevil

    To make it all work with the simplest steps, Yes, you need your target project to be /CLR:Safe. However this won't help if you have existing unmanaged code.

    "production code" means the code that you will eventually ship to your customers -- whoever or whatever they maybe.

    Unmanaged code is also called "native code" -- eg It is not executed ontop of the .net Framework or similar. All VC6 Projects are "unmanaged"

    Also look at:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=19692&SiteID=1



  • I cannot create unit test for my application?