Search code examples
mstestcode-coveragesigningstrongname

How to configure MSTest Settings to disable strong name signing for code coverage


I want to run code coverage in my unit tests.

The issue is that I sign with multiple files. MSDN indicates that this requires multiple test configurations (because code coverage config only allows selecting a single .snk file)

Can I configure the code coverage in my test config file to disable signing just during the unit testing so that I can keep a single test? I have read MSDN docs on adding the -vr to the sn as in
http://msdn.microsoft.com/en-us/library/ms243141(v=vs.80).aspx

But I don't see how I can do this in my test config.
Any suggestions?


Solution

  • The intention of using the SN -vr option is to

    disable signing verification, for this assembly, for the duration of your test run

    So actually, you just do not re-sign your assemblies for the testing phase, and before you execute the tests you disable assembly signing verification on the computer system that your test will be running on using the SN -vr option.

    To do this in your testing sequence you can use the Setup and Cleanup Scripts page in your test configuration file. Use the Setup script line to invoke a batch script that will disable assembly signing verification for the involved assemblies on your test system. Use the Cleanup script line to invoke a batch script that will enable assembly signing verification again.

    That should work fine ...