how to update code coverage toTFS 2013 using backend tool NUnit - visual-studio-2013

we have created NUnit test projects with Visual Studio 2013 ,enabled code coverage using build process with TFS 2013 connectivity, the build is performed successfully but we are not able to see the code coverage with in the build report.
it shows us "No Code Coverage" message .
Please provide us the solution on the same.

Related

TFS 2015 Publish attachment to Test Run Summary

Is there a possibility to add a custom file (e.g. custom Selenium report for all tests) into the body of Run summary itself (Runs -> Run Summary -> Attachments).
Tests are executed using the vNext "Run Functional Tests" task, the unit framework used in tests is a TestTools.UnitTesting.
I know that there is a TestContext.AddTestResult but it attaches file to a specific test, while I want to use some sort of a summary file for the whole run.
Test Run Summary in question
If you want to display your custom result in the test run summary or build result summary, seems you will have to write your own extensions. Help link: Overview of extensions for Visual Studio Team Services
Base for this were a lot of examples provided by MS on github:
Visual Studio Team Services Tasks
Visual Studio Team Services Sample Extensions
To get a first feeling what places on your TFS Web Portal can be extended/customized you can download and install this extension Contributions Guide from the Visual Studio Marketplace.

How do I run code coverage analysis for my tests automatically after building my solution

How can I execute Code Coverage Analysis on my unit tests automatically each time I execute a build process from my development machine?
I have searched the internet but I have not found any related questions or posts.
According to info from MSDN:
In Team Explorer, open Builds, and then add or edit a build definition.
On the Process page, expand Automated Tests, Test Source, Run Settings. Set Type of Run Settings File to Code Coverage Enabled.
If you have more than one Test Source definition, repeat this step for each one.
But there is no field named Type of Run Settings File.
Under Automated Tests, select Test Assembly and choose the ellipsis button [...] at the end of the line. In the Add/Edit Test Run dialog box, under Test Runner, choose Visual Studio Test Runner.
After the build runs, the code coverage results are attached to the test run and appear in the build summary.
Source:
Using Code Coverage to Determine How Much Code is being Tested (look for Analyzing code coverage in the build service)
Run tests in your build process
When you are using Code Coverage for testing, you will determine how much of the project's code is actually being tested by coded tests, in this case unit testing. Code Coverage is a feature that Visual Studio uses to guard against bugs etc.
Requirements are to have Visual Studio Premium
To use analyze Code Coverage in Visual Studio on unit tests in the Test Explorer in Visual Studio, follow the steps bellow:
On the Test menu in Visual Studio select the option Analyze Code Coverage
Then if you want to see which lines have been run, chosse the option Show Code Coverage Coloring
The Code Coverage Results will usually show the results of the most recent run that you have done.
The code coverage can also be used to view previous results.
The coverage coloring might be incorrect if the source code has changed since the .coverage file was generated.
For automated Code coverage do the following steps:
Select Test Assembly and choose the ellipsis button.
In the Add/Edit Test Run dialog box, choose Visual Studio Test Runner.
You can also Merge results from different Code Coverage Runs.
Here is a link if you want to Customize Code Coverage Analysis:
https://msdn.microsoft.com/en-us/library/jj159530.aspx
Here is a link for Analyzing Code COverage in Build Verification Test:
https://msdn.microsoft.com/en-us/library/jj159524.aspx
Here is a link for Troubleshooting Code Coverage:
https://msdn.microsoft.com/en-us/library/jj159523.aspx
Sources can be found here:
https://msdn.microsoft.com/en-us/library/dd537628.aspx

TFS 2013 Build Summary Not Showing Test Results

Similar issue as this question (which does not have an answer), except we are using TFS 2013 Update 4. Our tests are written using NUnit and are configured to run through the build definition, which uses the default (not upgrade) template.
We just installed a full version of VS 2013 Premium on the build server (because prior tests were not being run at all). With that installed, the tests are run (if I did down into the log I can see them and the results, and if we force a failure the build appropriately fails) but the build summary says that 0/0 tests were run.
I followed the steps in the selected answer to this question, and it now shows the code coverage results, but still no dice on the actual tests or their results.
I also found this blog article that appears to be the same issue from TFS 2010. I have verified that all users have the View Test Runs permission set to allow, and I tried using a TFS administrator account just to be sure. Still no dice.
How do I make TFS show me what tests were run in the summary, and also in the Test Results window that the build summary links to?
Each individual test needs to be associated with a test case work item in Team Foundation Server. See this link for information on how to associate your tests. In my work, we're using TFS 2015, but I know this works in TFS 2013 as I have done this work in the past. Once the test case work item is associated with your automation (using Visual Studio to link the test automation to the test case) then there must be a build definition for the product under test that runs your test automation as part of the build. When a build is queued, your tests are run as part of the new build. Once the build is done, you can then view the detailed test results.
Plus the other StackOverflow post here describes how to view the detailed results.

Visual Studio 2013 cannot find Ms Test.exe for Test Runner, only VsTest available

In VS 2013 there seems to be no option to select MSTest instead of VsTest in the Test Runner Dropdown which is also grayed out. Is there a way I can add Mstest to this list as was the case in Vs 2010.
The ability to select MsTest in the Build Definitions of Team Build 2013 is no longer available in the default build process templates. You can still create a custom build process template that runs the old runner, but be aware that the old MsTest runner is in fact considered deprecated.
The dropdown is disabled and there is no way to enable it in the out-of-the-box build process templates.

How to Run the Unit Test As the part of Build (Not continuous integration)

I have Nunit unit test which i need to run as the part of my MS build.. I know that running all the test will slow up the build So, i need to run only the impacted test is there any way to find that out..
AFAIK running only impacted tests is not possible yet for NUnit tests. But this is possible for MSTests in Visual Studio 2010 Ultimate/Test Professional:
Recommending Tests to Run That are Affected by Code Changes
You can use Visual Studio Ultimate or Visual Studio Test Professional
2010 to help you determine which tests might have to be run, based on
coding changes that were made to the application you are testing. To
be able to use this functionality, you have to use Team Foundation
Build to build your application and use Microsoft Visual Studio 2010
for version control for your source code
Anyway you can use MSBuild Community NUnit Task to run tests from a set of the assemblies. You can do this as dependency target of standard AfterBuild target by specifying DependsOnTargets attribute.
<NUnit Assemblies="..."
IncludeCategory="..."
ExcludeCategory="..."
ToolPath="$(NUnitDllsPath)"
ProjectConfiguration="$(Configuration)"
OutputXmlFile="$(NUnitOutputPath)\UnitTests.xml"
ContinueOnError="true">
To know the impacted tests you need to track the test case code coverage. Only this way you can examine what test is impacted by the changes you are checking in. I don't know of any tool that does what you want besides Microsofts Team Foundation Server.
Running your tests as a part of the build can be done trough the Build Events properties of your project. You can execute the command line tool for NUnit.
But as PVitt already pointed out, I don't know if NUnit can work with Test Impact analysis.

Resources