MSTest hangs when executing web tests - mstest

I'm working on a test migration of a TFS server from 2010 to 2012. We've taken a proof-of-concept server and successfully upgraded it to TFS2012. Now we're trying to repurpose an older build controller, running TFS2010 on Windows 2003 , to run the builds. The builds are a bit on the ancient side; they originally were created for TFS2005 and were upgraded directly to TFS2010 at some point in the past, but still use MSBuild scripts and the Upgrade Template. The vast majority of the codebase is still targeting .NET 2.0 and VS2005, although this will be changing shortly.
So, that's the background. On the TFS2012 build controller, everything builds successfully and the tests run. Hooray! Now onto the problem.
On the TFS1010 build controller, everything builds successfully, but the web tests are "hanging". When executed manually from the command line, it just says "Starting Execution", and then sits there for a couple of hours and eventually times out. There are unit tests, and they do run, so it's something specifically happening with web tests.
What's interesting is that the TFS2012 build controller is obviously using the 2012 version of MSTest, in the \Microsoft Visual Studio 11.0\ folder, and the TFS2010 build controller is using the VS2010 version. When I run the same tests via the command line on the 2012 build controller with the VS2010 version of MSTest, the same issue occurs.
I've confirmed that the TFS2010 build server is running VS2010 Ultimate SP1, with all appropriate updates installed via Windows Update. It was originally running Premium, and the web tests not working actually made sense at that point. I did a complete uninstall of Premium, then installed Ultimate. TFS2010 is patched to SP1 and has CU 2 installed.
The TFS2012 server is running Update 2.
Here's a log from the build server of the issue occurring:
TeamFoundationServerUrl="http://[redacted]:8080/tfs/eCommerce" BuildUri="vstfs:///Build/Build/46594" (TaskId:4359)
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe /nologo /usestderr /testSettings:"G:\Builds\19\124\Sources\Main\Source\ES_[redacted].testrunconfig" /searchpathroot:"G:\Builds\19\124\Binaries\ESIntegration" /resultsfileroot:"G:\Builds\19\124\TestResults" /testmetadata:"G:\Builds\19\124\Sources\Main\Tests\WebTests\Common\SmokeTests\SmokeTests.vsmdi" /testlist:"Division1" /testlist:"Division2" /publish:"http://[redacted]:8080/tfs/ecommerce" /publishbuild:"vstfs:///Build/Build/46594" /teamproject:"Web" /platform:"Any CPU" /flavor:"ESIntegration" (TaskId:4359)
Loading G:\Builds\19\124\Sources\Main\Source\ES_[redacted].testrunconfig... (TaskId:4359)
The file 'G:\Builds\19\124\Sources\Main\Source\ES_[redacted].testrunconfig' was created in an earlier version of Visual Studio. This file will be converted, in memory only, to the current format. (TaskId:4359)
Loading G:\Builds\19\124\Sources\Main\Tests\WebTests\Common\SmokeTests\SmokeTests.vsmdi... (TaskId:4359)
(TaskId:4359)
Search path(s) for tests: (TaskId:4359)
G:\Builds\19\124\Binaries\ESIntegration (TaskId:4359)
G:\Builds\19\124\Sources\Main\Tests\WebTests\Common\SmokeTests (TaskId:4359)
Search path(s) for default test settings: (TaskId:4359)
G:\Builds\19\124\Sources\Main\Tests\WebTests\Common\SmokeTests (TaskId:4359)
(TaskId:4359)
Starting execution... (TaskId:4359)
(TaskId:4359)
Results Top Level Tests (TaskId:4359)
------- --------------- (TaskId:4359)
Timeout (Division1/)SmokeTests.Division1 (TaskId:4359)
Timeout (Division2/)SmokeTests.Division2 (TaskId:4359)
0/2 test(s) Passed, 2 Timeout (TaskId:4359)
Note that the tests have the same issue when running from the IDE on the build controller.

I did a total uninstall of VS2010 and TFS2010, then reinstalled everything in this order:
VS2010 Ultimate
All VS2010 updates from Windows Update
VS2010 SP1 (from Windows Update as well)
TFS 2010
TFS 2010 SP1
TFS 2010 SP1 CU2
TFS 2012 Compatibility GDR
Then I configured the build server and agent. Now it works as expected.

Just for reference, I'm experiencing the same issue. When you reinstall VS2010 SP1 then MSTest works for VS2010, but breaks for VS2012. Probably a shared component. It's a bug: http://connect.microsoft.com/VisualStudio/feedback/details/728659/mstest-not-working-after-installing-vs11-next-to-vs10#

If this helps anyone, I ran into this problem because I had a "PAUSE" statement in my setup script batch file.

Related

How to connect OpenCover to VS tests

OpenCover 4.7.922 installed in VS 2015 Community, and appears in VS menu bar, but the link to my Tests is broken. Project is a C# console app.
This was working a while ago, with the same project. Possibly disturbed by (1) installing VS 2019 (Now Community 2015 and 2019 are both installed) and (2) updating OpenCover.
OpenCover Text Explorer should find my tests, enabling me to run them. But no tests are found. Likewise, under Test Explorer, "Run selected tests with OpenCover" is disabled (greyed out).
It's working now. Final stage was to delete the test project entirely and rebuild it, and make sure all projects use the same Target framework.
In summary, I am getting my code automatically colored (covered / not covered) using VS Community 2015, Target Framework 4.5.2, OpenCover 4.7.922, NUnit 3.12.0.

TeamCity on EC2 - MSBuildTools Path Not Found, yet manually installed on 2012 Server R2 (AWS)

I'm hoping to get some assistance from you smart people!
I had my CI tool, TeamCity, compile solutions without a problem when VS 2015 was installed however I read from multiple sources that TeamCity does not need VS
Subsequently, I created an EC2 instance and installed JDK, MS BuildTools 2015, the Build Agent, and PsExec on my Build Server and connected it to the EC2 server housing the TeamCity client.
Unfortunately, it is giving off errors for a simple solution. -- http://imgur.com/M8sdDRs
I moved folders from my dev machine to the CI build agent server
Actually, you don't need to install Visual Studio 2010 or Visual Studio 2012 on your CI server. You only need to copy a few folders from a development machine to the same location on the CI server.
• C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
• C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications
The problem is still persisting and I've come to a stand-still and frustrated with the problem.
THANKS SO MUCH!
If you're using the Visual Studio (sln) step runner type then you will need VS installed because that requires devenv.exe to build the solution. Unless you've got specific requirements for that, you should probably switch to using MSBuild as your build engine to remove the dependency on devenv.exe. Configure a build step of type MSBuild, point it at your solution and select Microsoft Build Tools 2015 / 14.0.
I doubt all your problems magically go away though, as you'll still need to stage bits of MSBuild like you've mentioned (WebApplications targets etc). I've had major hassles over the years trying to get a stateless, dependency 'free' agent build configured; Windows / .NET SDK is a can of worms.
Recommendation from TeamCity - Install VS on the CI Server to minimize the potential for errors. I installed the full Community Version, though VS Isolated Shell was fine as well, I wanted to minimize the room for error.
I ensured that: Administration > [Project] > Build Configuration Settings > Agents Requirements had MSBuildTools14.0_x86_Path existing and set my parameters to follow the following great resource - http://blog.anthonybaker.me/2013/04/how-to-automate-builds-with-teamcity_3119.html

NUnit failed to load in TFS build

I’m having a "build partially succeeded" issue with this error “NUnit failed to load e:\Builds\184\CSTax\706USServices_Test\bin\Calc.Tests.dll”, but all of the unit test in this project ran and passed (all green).
Build environment
1) Using NUnit 2.6.4 and NUnit Test Adapter 2.0.0
2) TFS 2013 – upgraded from 2012
3) Visual studio 2012 and 2013 have been installed on the server
4) I did install the NUnit Test Adapter, using the Extensions and Updates in 2013 Visual Studio
5) Using build process templates from TFS 2012, even if I switch to the 2013 default build process templates I get the same error
6) I tried changing the project to copy the nunit references locally (including the test adapter), they did make it to the bin folder, but still fails
7) I used process monitor to see if I could find the failure, everything looked good, the dlls were copied from the packages folder to the bin folder and loaded.
I’m sure it has to be something in our build environment, but I do not know where to look, I need my builds to go green. Any ideas?
The issue is a bug in the NUnit 3.0 test adapter, I removed our E2E project off of the build server and all my builds went green. NUnit is looking into this bug.
You need to:
Download the NUnit test adapter: https://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d . Rename the NUnitVisualStudioTestAdapter-2.0.0.vsix to NUnitVisualStudioTestAdapter-2.0.0.zip. Unzip NUnitVisualStudioTestAdapter-2.0.0.zip.
Check in the following dlls: nunit.core.dll, nunit.core.interfaces.dll, nunit.util.dll and NUnit.VisualStudio.TestAdapter.dll into a folder in TFS Version Control.
Specify the build controller's path to custom assemblies:
Then queue a build, the NUnit test methods will be run.
Also have a check on the Enable a third-party unit framework part of this MSDN article for the details: https://msdn.microsoft.com/en-us/library/vstudio/ms253138.aspx

Visual Studio 2012 Professional - unit tests not working

After building my application I get in the test output:
------ Discover test started ------
Exception has been thrown by the target of an invocation.
========== Discover test finished: 1 found (0:00:01,457) ==========
I'm using Visual Studio 2012 Professional on win7 32bit.
Tried:
repairing vs2012
reinstalling vs2012
changing configurations
changing path to
Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Nothing worked...
Any ideas?
Previously I worked with Visual Studio 2010 Express edition.
Application is correct - I made just simple class library and test project just to be sure it works. And it doesn't. The same project works with my student premium version.
Ok
I looked again in http://connect.microsoft.com/visualstudio and tried also:
moving project files to another location than default
changing security rights in files and folders properties
run vs as administrator
Nothing really worked until i found by chance vs2012 update 1
(under the "Additional Software" category)
After download and installation everything works fine.
In my case, right clicking and selecting "Debug Tests" on a test method would not do anything. It was an existing test project. The issue was that the test project was not even included in the solution's build list. Somebody took it out from the solutions build list. Anytime I would select "Debug Tests", the projects were built but nothing happened.
Confirm that the test project is going to be built with the solution by right clicking on solution in the solution explorer, and then configuration manager. Ensure that the test project is checked-on for build. Those minor things that cause big problems!

TFS 2010 is trying to run MsTest 2010 project under MSTest 2008

I've got a CI build set up to build my solution and run my unit tests. The solution is VS 2010. My test project targets the 4.0 framework. And the 10.0 version of the Unit Test Framework is properly referenced. If I run the tests locally in VS 2010, I have no issues. However, when I run my CI build on the TFS server (which is TFS 2010), I get an error stating:
File not found: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe
This is the MSTest for VS 2008, and it's not installed on my TFS server. I do have VS 2010 installed on my TFS server including the testing tools but TFS doesn't look for it.
My question: Why would TFS be attempting to use this version of MSTest to run the tests? I can't find this path specified anywhere in any project, solution, or configuration on the server.
The solution and related projects began life as VS 2008 projects and were migrated to VS 2010. These files were pulled into a fresh install of TFS 2010 and a new TFS project. They were not migrated from a 2008 TFS server.
Activity Log
Full Log
Thanks!
Just a follow-up on this because I eventually discovered what was causing my issue and it was not the answer given above. We were referencing a third party assertion utility kind of like "Should" called "SoftwareApproach.TestingExtensions" in this project. This dll was an older one and contained a reference to MSTest 9 (from VS 2008). Because this dll referenced MSTest 9, it was causing this error on the build server, however, the test would run locally. Frankly, not sure why it didn't complain locally as there was no binding redirect and VS 2008 is not installed.
However, updating to a build of the mentioned dll that instead referenced MSTest 10 resolved our issue on the build server.
From looking at the logs, the problem is that MSTest is running here using the wrong version because you have a legacy assembly reference.
Make sure your unit test project and any other projects being executed for test have the correct assembly reference to the new mstest assembly. I am guessing you either missed a reference or added in the new reference and forgot to remove the legacy one.
"I can't find this path specified anywhere in any project, solution, or configuration on the server."
Yeah, you wouldn't see the path anywhere- it will just exec based on what assembly is referenced into the unit test proj.

Resources