How do I remove test projects from code coverage in Visual Studio 2012 15 September 2013 Donovan-Brown Work (0) Problem: My code coverage results include my test project classes. Solution: Apply the ExcludeFromCodeCoverage attribute to your unit test classes.
How to enable code coverage in my Team Build 03 October 2011 Donovan-Brown Work (0) Problem: I am not getting code coverage results in my build. Solution: Ensure you have a test settings file selected in your build definition. Explanation: On the process tab of your build definition expand the Automated Testing section under Basic and make sure the TestSettings File is pointing to the test settings file that has code coverage configured. You can watch a video below that demonstrates how to do this.
I don't want Entity Framework code counted in code coverage. 29 September 2011 Donovan-Brown Work (0) Problem: The code generated by the Entity Framework is distorting my code coverage numbers. Solution: Add a Code Generation Item and add the [DebuggerNonUserCode] attribute to the generated classes. Explanation: As I described in a previous post here the [DebuggerNonUserCode] hides the code from code coverage results. I am a huge fan of code coverage however; I do not see the point in testing generated code especially when most of it is just value objects. Entity Framework uses T4 Text Templates to generate the typed ObjectContext and EntityObject derived entity classes used in your code. If the code generated does not fit your needs you can add a Code Generation Item to your project and the Entity Framework will use your custom T4 Text Template to generate the classes. Adding a new Code Generation Item is very easy. Simply open your .edmx file and right click on the design surface and select Add Code Generation Item… from the context menu. When the Add New Item dialog is presented select the Code section under your language of choice. You will be presented two generator templates to choose from. The ADO.NET EntityObject Generator template generates the same code as the default code generated by the Entity Framework Designer. In solution explorer you will see a new file with a .tt extension. This file will create a .cs (or .vb) file which appears under the .tt file in Solution Explorer. All we have to do now is modify the template by adding a using statement for System.Diagnostics and add the [DebuggerNonUserCode] attribute on all the partial classes in the template (there are 3). With the template in your solution all the Entity Framework code will be generated with the [DebuggerNonUserCode] attribute and removed from the code coverage calculations. You can download a copy of the T4 Template below. Model1.tt (45.02 kb)
I have code I don't want used to calculate code coverage or code metrics 02 September 2011 Donovan Work (0) Problem: I have code that I don't want to be calculated in my code coverage results and/or my code metrics. Solution: Apply the GeneratedCodeAttribute, DebuggerNonUserCode or DebuggerHidden attributes to the specific code. Explanation: GeneratedCodeAttribute DebuggerNonUserCode DebuggerHidden Code Metrics Excludes code No Effect Code Analysis Excludes code No Effect Code Coverage No Effect Excludes code
I can't get Code Coverage to work on IIS7 13 January 2011 Donovan-Brown Work (0) How to get code coverage on IIS7. [More]
Lap around dev vsts 2010 dev tools 02 June 2010 Donovan-Brown Work (0) Lap around the VSTS Dev Testing Tools [More]