Running MSTEST.exe /publish on a TeamBuild server, what are the prerequisites? - tfs

Similarly to How to use MsTest in Continuous Integration without VS?, I want to run mstest.exe on a TeamBuild server.
My context is Trapping Error Status in MSBuild - i.e., I'm only trying to use mstest.exe /publish to upload the results in to the TFS repository. Thus the full rigmarole in http://www.shunra.com/shunrablog/index.php/2009/04/23/running-mstest-without-visual-studio/ is (you'd hope) likely to be overkill, esp as MSTEST.exe, as covered in http://social.msdn.microsoft.com/Forums/en-US/tfsgeneral/thread/e4575890-8f88-413c-a7f3-0d09d3b9cb01 suggests all I need to do is install Team Explorer.
I've installed VS2008 Team Explorer SP1, and mstest.exe /? still isnt telling me about the publish options.
Recall that it says only Team Explorer is required of mstest.exe /? for publishing:
The following options are also available if Team Explorer is installed:
/publish:[server name] Publish results to the Team Foundation
Server.
/publishbuild:[build name] The build identifier to be used to publish
test results.
/publishresultsfile:[file name] The name of the test results file to
publish. If none is specified, use the
file produced by the current test run.
/teamproject:[team project name] The name of the team project to which the
build belongs. Specify this when publishing
test results.
/platform:[platform] The platform of the build against which
to publish test results.
/flavor:[flavor] The flavor of the build against which
to publish test results.
I'm going down the procmon.exe path to figure out what's missing, but ideally someone in the know would step in and answer:-
Should mstest.exe /publish only require Team Explorer as stated, or does it require VSTT and Team Explorer?

The /publish option of MSTest.exe does a license check to ensure that a "Team" version of Visual Studio is installed (i.e. the Developer or Test edition) before it does the publish part of the code.
This restriction appears to have been introduced to allow the basic unit testing capabilities in standard versions of Visual Studio but requires you to have one of the more expensive Team editions of Visual Studio to enable the "Team" related features in testing - such as to publish your test results to TFS.
In total there are 3 missing features if you do not have a Team edition of Visual Studio with Team Epxlorer installed.
Publishing to TFS
Code coverage
Connect to remote agent.
If you have the Development Edition installed then you get publish and codecoverage but not the remote agent agent capabilities (i.e. for doing Load lesting).
The Test Edition and Visual Studio Team Suite have everything.
If you would like to see an example of a custom MSBuild task that uses MSTest.exe to publish unit test data from a build server (in this example JUnit test data), then take a look at the Teamprise Build Extensions that I wrote. The source code for these is available under the permissive MS-PL open source license.

I've read on the MSDN forums that the /publish functionality of mstest requires purchasing either VS Team Developer or VS Team Test edition. Any lesser editions such as standard/professional or team explorer don't have it.
I'd really like to see some more evidence though, as it seems fairly unreasonable that with "standard" VS2008 you can write and run unit tests, but you arbitrarily can't run them on your build machine :-(
To answer the question:
Should mstest.exe /publish only require Team Explorer, or does it require VSTT and Team Explorer?
It appears that it requires VSTT (which I assume means visual studio team-tester edition)

Well, the message you get when running mstest.exe /? is actually very misleading. It tells you that Team Explorer is required to publish your test results, but unfortunately installing Team Explorer doesn't change anything. As Martin stated, MsTest does a license check to ensure that appropriate edition of Visual Studio is installed and thus '/publish' and other switches are not available.
And by 'appropriate' edition MsTest means Premium or Ultimate, not sure about other editions.
Microsoft says you should install Visual Studio on your server to have a fully featured CI and this is the only official and supported solution, but if you really don't like this concept (and I don't), you can make MsTest think that Visual Studio is installed on your server.
It is enough to export some registry keys from your development machine to your CI server and voila! - MsTest does publish your test results to TFS.
The registry keys are at
HKLM\SOFTWARE\Microsoft\VisualStudio\12.0\Licenses
or at
HKLM\Software\Wow6432Node\Microsoft\VisualStudio\12.0\Licenses
depending on your system.
You can find more details of this solution here:
http://blog.foxxtrot.net/2010/02/hacking-mstest-out-of-visual-studio.html

Related

How do I install prerequisites for TeamCity to connect to Team Foundation Server Version Control?

I've installed the prerequisite (Team Explorer 2013) to the best of my knowledge, but when I try to set up a VCS root to connect to our TFS Version Control server, I continue to get this error message:
"No TFS assemblies were found on the system. Please make sure you have
Microsoft Team Explorer installed. Supported versions: 2015 2013 2012
2010 2008 2005"
The Team Explorer I downloaded from Microsoft just seemed to be a plugin for Visual Studio, which doesn't make much sense as a server-side component. Anyway, I configured a connection to our TFS box within Team Explorer/Visual Studio on my TeamCity server.
So I have two questions that seem to be undocumented by JetBrains:
What does it mean to set up and configure Team Explorer? How can I validate that I have set up and configured Team Explorer on my TeamCity server correctly?
How does TeamCity know how to find the Team Explorer assemblies? Is there some sort of configuration I am supposed to do? Where is this documented?
I guess I'm looking for a true step-by-step set of instructions that make no assumptions about my understanding of TFS or Team Explorer, or any assumptions about what I may have already installed on my TeamCity box.
I've read the two articles on the JetBrains site regarding how to set this up, and they don't cover actually installing and configuring the prerequisites or configuring TeamCity to discover the Team Explorer assemblies it needs.
Team Explorer is the client software that you use to access Visual Studio Team Foundation Server functionality from Visual Studio. You can simply launch Team Explorer on your TeamCity server to create a team project and check in a project, to validate whether it is installed correctly.
I couldn't find any documentation that mentioned how does TeamCity find Team Explorer assemblies. But, based on my understanding, there is no configuration needed to detect Team Explorer. Please make sure your TeamCity server is running under Windows.
If the issue that can't find Team Explorer persists, you can install VS Premium instead of Team Explorer.
Setting up Jetbrains TeamCity for CI with Team Foundation Server:
Install Jetbrains TeamCity
If you are planning on using IIS or TFS on the same server, configure Jetbrains TeamCity to run on a port other than 80 or 8080
Once TeamCity is up and running, you can begin configuring your TeamCity installation for CI Builds.
Log into TeamCity with your user name and password
Create a new TeamCity Project
Create a new build configuration
You will now see a series of build configuration settings that you will have to complete presented in a Wizard-style navigation view.
Enter General Settings
Enter VCS Settings
After entering VCS Settings, Create and attach new VCS Root
Enter the relevant information for your TFS instance
Create a Build Step using Visual Studio as your build runner. You can create as many build steps as you need and specify the order of the steps (similar to a TFS Build Workflow).
For setting up Continuous Integration builds, you will need to specify a Build Trigger. CI Builds will generally use a VCS Trigger that is triggered on each source control check-in.
If you need to pass any parameters to your build, you can configure these in your Build Parameters.
That is all! You can then either run your Builds manually by clicking on the Run button in TeamCity or simply verify that your builds are triggered by the next check-in into TFS.

TFS 2013 - No Code Coverage Results

I have a TFS 2013 environment setup and I am trying to get TFSBuild to gather my code coverage results after a build.
The tests are running fine, but no matter what I try, I get a message saying "No Code Coverage Results".
I have read about a "Code Coverage Analysis Service", but that is not installed on my servers at all and I can't seem to find it anywhere.
I have gone through the process of the builds to make sure I have the "Automated Tests --> Test Source --> Run settings --> Type of run settings" set to CodeCoverageEnabled, but no matter what else I try, I can't get the results to get published to the Analysis services database so I can run the Code Coverage Reports.
I have tried a run settings file, but with no luck, so I have taken that out of the equation.
Any help would be greatly appreciated!
I just figured out what the problem was that my Code Coverage weren't been calculated on the buildserver. I figured this out with the helpdesk of Microsoft and it is a small UI bug.
Steps to reproduce: Create a new build definition.
Go to the process tab of the build definition and select the solution file to build.
Now expand the "Automated tests" section and expand the "Test Source".
Expand the "Run settings" and change the "Type of run settings" from "Default" to "CodeCoverageEnabled".
Save the builddefinition and run your build.
Examine build results and notice no code coverage is calculated.
To fix this issue use the other ui of the build definition.
Select the "Automated tests" node.
Now in that row on the right you will see a button with "...". Hit it and a dialog will be opened.
Hit "Edit" to edit your test source. You will see that Code coverage is enabled. If not select it.
Hit Ok and Ok again to close the two dialogs.
Now save the build definition and run your build again.
Now the code coverage does get calculated!!! The microsoft helpdesk has submitted a bug to the development team and it will be fixed I guess the next release. Small bug but it cost me more then two days to find the bug!
Do you have a Premium or ultimate visual studio installed on your build machine? Either of those is required to get code coverage results back to TFS
I think the "other window" is referring to right-clicking on the Solution's "Local.testsettings" file (or other [ ].testsettings files), selecting "Open" and navigating through the various setups. When you set the "Test Run location" radio button to "Run tests using local computer or a test controller", there is a setting under "Data and Diagnostics" for "Code Coverage (Visual Studio 2010)".
I am using local build server with Visual Studio online with a .runsettings file and I had exactly the same issue.
None of the trickery above helped, so I tested the build script on the hosted build controller and it worked fine, so I decided the problem must be the build server itself.
I changed the Build Service account from "Network Service" to a regular windows user account in the TFS Configuration Tool and now code coverage is collected. Note that this user will need access to the TFS build directories.
The above workarounds didn't work from me (VS2015 update5 & TFS2013 Update 3).
In my case, Visual Studio was not installed on the build server which is a requirement it seems for code coverage results to be returned.
From MSDN
Microsoft Visual Studio is required to be installed on the build server for the following scenarios:
To build any CPP test project, you must install Visual Studio Professional or later.
To run unit tests, or coded UI tests, you must install Visual Studio Professional or later.
To use data and diagnostic data adapters:
- Code coverage: Visual Studio Premium or later.
- Test impact: Visual Studio Ultimate.
- IntelliTrace: Visual Studio Ultimate.
To build any modern style apps on a build machine: Visual Studio Ultimate or Visual Studio Express for Windows 8 (Operating system on build server must be Windows 8).
To compile and run tests for a project with a faked assembly: Visual Studio Ultimate.

TFS 2012, TFSBuild.proj, UpgradeTemplate.xaml process definition and Coded UI Tests

Another few TFS questions if anyone can help even remotely :-)
We currently have TFS 2012 installed. We have 2 servers (both VMs running Windows Server 2008 R2 x64). One server is TFS with the application layer and database (running SQL Server 2008 R2) installed. The other server is our BUILD server with the build controller and build agent installed on it.
We can connect to TFS 2012 OK from our local developer PCs using Visual Studio 2012 Ultimate.
We then have various complex build definitions that compiles our code, runs unit tests, generates real-time sandcastle documentation and installs to our multi tiered, multi server TEST or LIVE environments using InstallShield (takes SSL and performs pre-install conditions etc)
We are using the UpgradeTemplate.xaml build process definition along with TFSBuild.proj file. FYI it was originally developed in TFS 2008 and has served us well hence why we don't WANT to upgrade to a modified defaulttemplate.xaml
We now want to include "post deployment tests" (aka smoking testing or system testing or end-to-end testing I believe) in the form of Coded UI tests.
We can record these tests locally, add asserts etc and check them into TFS etc but my problem is how to invoke them from TFS Build at the end of our build sequence without upgrading to a defaulttemplate.xaml? We use the true build property to invoke our unit tests but this is run prior to deployment. What other property(s) do i need to set? is this at all possible?
I have googled/MSDN'd an believie we may need a third server with a test controller and test agent on it (that isnt locked with a screen saver, build service account has permissions and the build service is configured to run as an internative process and not a service). Is this correct?
If we want to video record the tests as they are run have people found this useful? Does it function/configure as easy as articles seem to imply?
Can visual studio 2012 Ultimate do everything that Microsoft Test Manager 2012 does? and vice-versus? I haven't used this and wonder if this a testers tool only really?
1.
We can record these tests locally, add asserts etc and check them into TFS etc but my problem is how to invoke them from TFS Build at the end of our build sequence without upgrading to a defaulttemplate.xaml? We use the true build property to invoke our unit tests but this is run prior to deployment. What other property(s) do i need to set? is this at all possible?
If the coded ui test is used as a stand alone unittest in the unittest dll, mstest should pick up the coded ui tests. If the coded ui test is however an automation of a test case, an alternative is to use the TCM command line tooling to kick of the test case and thereby executing the coded ui test.
2.
I have googled/MSDN'd an believie we may need a third server with a test controller and test agent on it (that isnt locked with a screen saver, build service account has permissions and the build service is configured to run as an interactive process and not a service). Is this correct?
Yes: You would need an interactive build agent.
No: the current build agent could also be set to interactive.
3.
If we want to video record the tests as they are run have people found this useful? Does it function/configure as easy as articles seem to imply?
Yes: It works as the articles imply
No: The intellitrace collectors and logs are usually more useful than a video recording. The articles also forget to mention that your TFS server might grow out of proportions if not handled with care. http://geekswithblogs.net/terje/archive/2011/11/15/guide-to-reduce-tfs-database-growth-using-the-test-attachment.aspx
4.
Can visual studio 2012 Ultimate do everything that Microsoft Test Manager 2012 does? and vice-versus? I haven't used this and wonder if this a testers tool only really?
No, there not the same and don't try to pretend that (like blend). The focus of the tools are different; MTM is focused on testing by a tester (functional, manual, exploratory), testing in visual studio is focused on testing as a developer (unittest, webtesting, automating tests). Visual Studio ultimate therefore can't edit and create test cases and suites. MTM can't create develop (coded) unittest tests. Installing visual studio ultimate also installs MTM, so you can use both if needed.

Running Unit Test with Microsoft Moles Host under Visual Studio 2010 Remote Test Agent in TFS Build

We would like to have our TFS automated CI build and test process use a remote test agent to run our tests separate from our build agent. On normal unit tests that do not use moles or moles host, we have no problems. However, when we include a moles host in our .testsettings or have a moles hosted test (via the HostType("Moles") attribute), the test agent seems to try and get the path to the moled .dlls that the build agent uses. It is almost as if the build agent passes a full path to the test agent and the test agent uses it. We either get a "You do not have the appropriate permissions to perform this action" (when in fact each service is running with administrative rights) or a cryptic "MSTest failed returned code 1 expected 0" and no logging information.
My questions for the group:
Has anyone gotten MSTest, Moles, TFS Build, and Visual Studio 2010
Test Controller/Test Agent (not part of the Test Lab setup) to work?
If you have gotten it to work, what is your setup?
It doesn't work.
While my scenario WAS in TFS Lab Mgmt, I found the problem really didn't relate to lab mgmt, but instead in the fact the the Moles installer looks for registry keys just don't exist when you only install the remote Test Agent without VS 2010 installed. See the following question for my Question & Answer:
Microsoft Moles HostType errors in TFS 2010 Lab Management environment
I stress that while I was using TFS Lab Management, it didn't matter. The issue occurs any time you want to run remote tests with VS installed.

Automated builds of BizTalk 2009 projects using Team System 2008 Build

I'm trying to configure automated build of BizTalk 2009 projects using Team Foundation Server 2008.
We have a staging server which has BizTalk 2009 installed. I ran the Team Foundation Server Build Setup on this server, and it can build non-BizTalk projects OK. However, BizTalk projects fail to build. I suspected something was amiss when "Deployment" was not a valid build type! I tried copying various things over from a developer PC which has BizTalk and Visual Studio 2008 installed, but still couldn't get it to work.
I don't really want to install Visual Studio on the staging server, but without it the "Developer Tools and SDK" option in the BizTalk install is greyed out. I guess I need this in order for BizTalk projects to compile.
So, my question is can a BizTalk 2009 server be used as a TFS build agent to build BizTalk projects without having Visual Studio installed. If the answer is no, what's the smallest part of VS that can be installed to get this to work?
Randal van Splunteren answered on MSDN:
There is a BizTalk installable feature called 'Project Build Component' (under 'Additional Software'). You can select/unselect it during installation of BizTalk. . . . It allows for builds without Visual Studio.
Be aware that you can only build stuff. For generating MSI packages you will need a BizTalk server (remote or on the build server itself).

Resources