MSTest does not execute unit tests - visual-studio-2010

When I try to run my unit tests, either in the Visual Studio 2010 IDE or from the commands line (via mstest /testcontainer:my.dll), I get this error:
Failed to queue test run 'kootsookosp#TFSSERVER 2011-06-28 11:00:11': Method not found: 'Void Microsoft.VisualStudio.TestTools.Agent
.AgentProcessManager.SetCurrentPlatform(System.Reflection.ProcessorArchitecture, Microsoft.VisualStudio.TestTools.Common.AssemblyClr
Version)'.
Most other posts regarding mstest errors suggest an issue with security, but this seems different.
Googling the above error message doesn't appear to show anything much that seems relevant.

Is my.dll 64 bits? MSTest does not support that.

Related

NUnit VS Adapter do not discover tests due to FileNotFoundException, Exception converting tests

When trying to run tests via Visual Studio Test Explorer, I got following error for all tests in solution (those that use Typemock and those that don't):
[2/12/2018 11:35:36 AM Informational] NUnit VS Adapter 2.1.1.0 discovering tests is started
[2/12/2018 11:35:37 AM Error] Exception System.IO.FileNotFoundException, Exception converting Manager.Tests.MessageLoggerTest.AddMessage_WhenAddMessageIsCalled_ThenAddMessagesToList
...
I found only one mention of the problem online on Xamarin forum, but with no fix (https://forums.xamarin.com/discussion/119513/xamarin-ui-tests-filenotfoundexception).
I use Visual Studio Enterprise 2017, version 15.5.6, NUnit 2.6.4, NUnitTestAdapter 2.1.1 and Typemock 8.6.0.22.
Running tests via Typemock runner (Test Navigator) works as expected.
EDIT
I feel a bit embarrassed, I cannot reproduce my original error. At work, we use multiple branches of the code base. Now, one branch works fine. I can discover and run tests via VS runner (Test Explorer).
On the other branch, when rebuild 1. test project I am getting StackOverflowException instead of FileNotFoundException. But it also discovers 41 of 43 tests that are in project. The 2. test project get also StackOverflowException and discovers none of 295 tests.
[2/20/2018 10:43:40 AM Informational] ------ Discover test started ------
[2/20/2018 10:43:44 AM Informational] NUnit VS Adapter 2.1.1.0 discovering tests is started
[2/20/2018 10:43:54 AM Error] The active test discovery was aborted. Reason: Process is terminated due to StackOverflowException.
[2/20/2018 10:43:54 AM Informational] ========== Discover test finished: 41 found (0:00:13.8969695) ==========
Have compared solution file, project files and NuGet package configs. Only difference between the branches was packages.config line:
<package id="Typemock.Isolator" version="8.6.0.18" targetFramework="net452" />
The working branch have targetFramework="net452", failing branch had targetFramework="net462". However changing framework to net452 didn't help.
Will have to dig deeper to see, what makes the difference. Thanks for anyone's help and time.
Try installing the NUnit 2 Test Adapter extension for Visual Studio from the gallery. This fixed the issue for me on a project also using NUnit 2.6.4.
I have faced the same issue.
In my case deleting temporary files in windows solved my issue.
Close visual studio. Go to Run and type %temp%. Clear all the files. Now the visual studio
will discover all the UI test case.

Visual Studio: Unit test fails to run with "Error: Could not find property 'MSTestDiscoverer.NeedsLegacyRunner'"

In Visual Studio 2015, when I initiate a run of my project's unit tests, the tests fail to start, and the following error appears in the Output window:
Error: Could not find property 'MSTestDiscoverer.NeedsLegacyRunner'.
What's causing this? How can I fix it?
Although I'm not sure what was causing this, I was able to fix it by doing a Clean Solution followed by a Rebuild Solution, and then restarting the test run.

How do I run MSpec in Visual Studio's test system using Gallio?

I'm trying to run MSpec tests in Visual Studio's test system using Gallio, but it appears to be ignoring the MSpec plugin from the IDE. What I did:
Installed Gallio
Added the MSpec NuGet package to my test project
Added the Gallio NuGet package to my test project
Copied the three files required for the MSpec Gallio integration to an "MSpec" folder in Gallio's installation directory
Wrote an MSpec test
Ran "All Tests in Solution" in the IDE
This yielded the following error
"No tests were run because no tests are loaded or the selected tests are disabled"
To check Gallio itself, I added a reference to MbUnit and created a simple MbUnit test. I also ran Gallio's other tools to check if the plugin was being picked up at all. I even restarted VS for good measure.
Results
Running the tests using Gallio.Echo or Gallio.Icarus successfully executes both MbUnit and MSpec tests, so the plugin is being picked up. Running the tests from Visual Studio runs the MbUnit test but not the MSpec test, so Gallio integration appears to be working (just not the MSpec plugin). Any thoughts?
Before anyone mentions it: yes, I'd rather be using ReSharper but licenses are not an option for my situation at the moment.
Update: The is now a project to integrate MSpec into VS2012's test system. It's available on the Visual Studio Gallery and the source is on GitHub.
After starting to debug the problem with both project's sources, it appears there are two underlying issues causing the incompatibility between MSpec and Gallio's VS runner. However, both issues stem from the fact that the VS runner uses Cecil to load type information from assemblies (presumably to avoid loading the test assembly into the main VS AppDomain).
I'll update this answer as I uncover more (hopefully resulting in one or more patch to fix the issues).
Issue 1: Nested types are ignored
I had been using nested types for my tests (SubjectSpec+when_something), which are ignored by the Cecil-based reflection used by Gallio's VS runner to avoid loading the test assembly into the app domain.
This ended up being a relatively simple fix, which I've submitted as a patch to the Gallio developers. I'll update this answer if/when I get confirmation of which release it will be part of.
Issue 2: MSpec causes "An exception occurred while invoking a test driver"
If the container type is removed to avoid issue 1, MSpec throws this error. The reason for this is that MSpec is trying to create an instance of the test object, but Gallio is only supplying it a wrapper Type object that can't actually be created.

Unit Testing Error - "Unable to get type" "Error: Could not load type" "from assembly"

I am getting this error with my new unit test:
Unable to get type MyTestProject.MyTestClass, MyTestProject. Error: Could not load type 'MyTestProject.MyTestClass' from assembly 'MyTestProject'..
I have other tests in the project that were working just fine and now they are all showing a similar error message.
If I run the test in Resharper (rather than the built in Visual Studio Test runner) then it works fine. (I would just use that, but it is slower.)
Any idea what this could mean?
It's also happens when library under test is in GAC.
It's offen case when you develop for SharePoint.
Remove library from GAC if you don't need it there or deploy newest version to GAC.
It seems to me that the Visual Studio unit test runner is a little bit behind on the naming of your unittests. This sometimes happens when you rename a namespace or class.
This should clear the interenal cache: unload the project from your solution, run all tests, than reload the project.
Worked for me.
I fixed this for myself by cleaning the test project and then building it.

Testing Visual Studio 2008 Package

I'm developing a Visual Studio Integration Package. When I try to run the Unit Tests that are included in the unit test project that is included in the template I get the following failure on the first test:
The test adapter 'VsIdeHostAdapter'
threw an exception while running test
'MenuItemCallback'. Call was rejected
by callee. (Exception from HRESULT:
0x80010001 (RPC_E_CALL_REJECTED))
It's intermittent- a new instance of Visual Studio always spins up, then sometimes it works but usually fails.
Turns out this is a known issue- the built-in tests have some problems.

Resources