locked
Remove unit test dependency from dll RRS feed

  • Question

  • I've got a solution with several projects (all native C++). At first these were several static libraries an executable and unit tests for the static library projects. Now I wanted to change to using dll's, mainly to reduce compile times. However I've got a slight problem with the unit tests.

    The unit tests need access to unexported functions of the library, so I've put the unit tests in the same project as the library they're testing. But now the main application tries to load the unit test dll (Microsoft.VisualStudio.TestTools.CppUnitTestFramework.x64.dll). However, I don't want the main application to depend on the unittest. And I actually also don't want the dll of the library to contain the unit test dependencies.

    Is there a way to remove the reference to the unit test dll, so I can run my main application with the same configuration as the unit tests? Or is the best solution to make a separate unit test configuration which will compile in the unit test while the other configurations don't?


    Thursday, April 24, 2014 9:05 PM

Answers

  • Hi BasvandenBerg,

    As you said that “The unit tests need access to unexported functions of the library”, in my opinion, you just need add the application reference to the unit test project which need to test. For that, the main application doesn’t need the test DLL files.

    For the unexposed method, we could use internal, then add this code below in the AssemblyInfo.cs file of the main application.

    [assembly:InternalsVisibleTo("Assembly name")]

    On the other hand, in my opinion, it’s better to let the unit test project and the main application project in the same solution.

    If I misunderstand you, please create a new simple project for that scenario and share it to me.

    About share the file in the OneDrive, please refer to:

    # Share files and folders and change permissions

    http://windows.microsoft.com/en-us/onedrive/share-file-folder

    Thanks

    Best Regards

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 28, 2014 2:06 AM

All replies

  • Hi BasvandenBerg,

    According to your description, I would like to know how do you call the unit test?

    In my opinion, we should add the necessary DLL files in the main application in order to initalize and run the tests.

    On the other hand, we could run the tests via mstest, in other words, in the windows form application, it could lunch the mstest.exe to run the unit tests.

    Thanks

    Best Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 25, 2014 12:54 PM
  • I run the test via the Test Explorer.

    My issue is that the main application doesn't need the unit test DLL to run, because it has no unit tests. Just the separate projects contain unit test. I would like to tell visual studio somehow that it doesn't need to propagate the unit test DLL as a dependency.

    Maybe the best solution is really to make separate build configurations. I will do that now until a better solution comes along.

    Friday, April 25, 2014 5:33 PM
  • Hi BasvandenBerg,

    As you said that “The unit tests need access to unexported functions of the library”, in my opinion, you just need add the application reference to the unit test project which need to test. For that, the main application doesn’t need the test DLL files.

    For the unexposed method, we could use internal, then add this code below in the AssemblyInfo.cs file of the main application.

    [assembly:InternalsVisibleTo("Assembly name")]

    On the other hand, in my opinion, it’s better to let the unit test project and the main application project in the same solution.

    If I misunderstand you, please create a new simple project for that scenario and share it to me.

    About share the file in the OneDrive, please refer to:

    # Share files and folders and change permissions

    http://windows.microsoft.com/en-us/onedrive/share-file-folder

    Thanks

    Best Regards

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 28, 2014 2:06 AM