title: VS2012 & TFS2012 Unit Test major issues
body: <p>We are using VS2012 and TFS2012 and write unit tests for our code. We want to report code coverage, and also using .config files in our unit tests for test appsettings, and also some other settings for logging, MS Enterprise library settings etc. etc. </p>
  
  <hr>
  
  <p><strong>App.config not working in new test framework</strong></p>
  
  <p>New test framework of MS should be great, but to me it is not so great at all.
  How I'm i suppose to set some basic configuration in config files, when the new framework does not use config files anymore?</p>
  
  <p>We had a problem with mixed mode dlls, and found a fix: adding</p>
  
  <pre><code>&lt;startup useLegacyV2RuntimeActivationPolicy="true"&gt; 
  </code></pre>
  
  <p>to the app.config. But this did not work for our unit test project. Becuase config files are not there anymore. Searching the internet came up with a solution </p>
  
  <p>'<a href="http://www.diaryofaninja.com/blog/2012/09/13/net-20-mixed-mode-assemblies-in-visual-studio-net-45-test-projects#.UFFl43wdOYw.dotnetkicks" rel="noreferrer">Problems with .Net 2.0 Mixed Mode Assemblies inside Visual Studio .Net 4.5 Test Projects</a>'</p>
  
  <p>This means editing a file of Visual Studio 11 itself in the program files directory, not a great solution i think....</p>
  
  <p>And how about some basic appsetting? How am I supposed to set this?</p>
  
  <hr>
  
  <p><strong>Do not use the .testSettings file</strong></p>
  
  <p>Using the old .testsettings file is also not recommended by MS, becuase then the old test framework is used. And if I use the .testsettings file, i cannot setup Code Coverage on my tfs2012 build service. </p>
  
  <p>Another issue is that we have code that need a dll (system.data.sqlite.dll), but only at runtime the unit test code needs this dll. So a reference is not needed. We fixed this by using the Deployment tab on the testsettings file. But in the new framework, you should not use the testsettings file. You have the [deploymentitem] attribute if you need files. But the deploymentitem attribute can only be used on a [testmethod] not on a [testinitialize] or [assemblyinitialize] method. But our code needs the dll in the [testinitialize] method. So there is no way to get the dll in place. </p>
  
  <p>Just copy it with File.Copy in the [assemblyinitialize] (or testinitialize) method does not work.</p>
  
  <p>Adding the dll as file to the project, and set the 'copy to output directory' to 'Copy Always' as mentioned in '<a href="http://msdn.microsoft.com/en-us/library/ee256991.aspx" rel="noreferrer">Configuring Unit Tests by using a .runsettings File</a>' also does not work at all.</p>
  
  <p>The (really not great) solution for this is to add the dll as a reference, then instantiate a class and do nothting with it. This way the dll is needed otherwise it is not building, and thus the dll will deploy itself to the right directories.</p>
  
  <hr>
  
  <p><strong>how to solve my problem(s)???</strong>
  - I want to use config files in my unit test.
  - I want to deploy some files that are neede in the 'assemblyinitialise' and/or 'classinitialize' methods.
  - I want Code Coverage on my TFS2012 nightly build enabled.</p>