Passing visual studio webtests fail in test explorer - visual-studio

I have a web performance and load testing project which executes as epected when I open the test definition and hit run however fails when i run through test explorer.
I have narrowed this down to only tests which reference another project in the solution (utilities project for custom validators).
when running tests via test explorer it errors with Request failed: Could not load file or assembly 'PerformanceTestingUtilities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. However works fine if I open the test and hit run.
What could be causing this to happen? I get no errors on build and nothing in the output.

Related

JetBrains Rider unit tests inconclusive due to: "Could not load type from assembly"

Rider's unit tests were working just fine, until I updated to VS 2022.
Now, whatever test I try and run, the result is immediately "Inconclusive", and the log that Rider generates for each test sessions shows the following:
19:03:58.028 |W| TestRunner: Discoverer [MSTest][Discovery][C:\projects\eng\src1\bin\Tests\Debug\net6.0\blabla.UnitTests.dll]
Failed to discover tests from assembly C:\projects\eng\src1\bin\Tests\Debug\net6.0\blabla.dll.
**Reason:Could not load type 'Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities.AssemblyHelper' from assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.**
And it's always with the same assembly. I should note that in VS 2022 the tests work as normal.

.NET Core 2.0 dependency issue

I have a library used in various project and made with .net core 2.0; the library is called 'Coconut'; the test is done on Windows.
When I try to build a simple test project to test some functionalities, the test code will not run.
The test is very simple:
but when I run it:
And the output is:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Could not load file or assembly 'Coconut, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
and the console shows the same problem:
What I don't understand is that the DLL that is not found is built in the same solution and everything was built through Visual Studio's tooling.
We can clearly see the dll in the same folder.
Edit:
When checking with procmon, there is not a single operation trying to load 'coconut.dll'; that string is completely absent from the log.

Is it possible to execute a load test, which uses a web test plugin by using MSTest command line?

I have a web performance test, which uses web test plugin. Based on this web performance test, I created a load test. When I run the load test from the Visual Studio 2013, the load test runs correctly on all my remote agents. However when I run the same test by using MSTest command line, I get an error indicating that the PlugIn (C#) was not loaded. My question is whether it is possible to execute a load test (with plugin) by using the command line MSTest? If yes, then what I need to do to get rid of the error?
Please note that I have already referenced the plugin in my visual studio projects (both web performance project and load test projects)
Thx
Here is the error that I get:
Run has the following issue(s):
Could not run load test 'ABC' on agent 'XYZ': Could not load
file or assembly 'PlugIn, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null
' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'PlugIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified.
When Visual Studio runs a test from within a solution it understands deployment items, such as DLLs for plugins and it deploys them automatically. By contrast mstest.exe does not do any automatic deployment. Hence you need to deploy the files yourself. That is commonly done via the "deployment" sections of a .testrunconfig or a .testsettings file.
Having specified the DLLs to be deployed in one of these two file types, add the corresponding /testsettings:{file name} or /runconfig:{file name} options into the call of mstest.exe.
See, for example, section 3 of this Microsoft blog.

MSTest on x64 C++/CLI

I got a problem using MSTest on x64: The test project depends on a couple of C++/CLI assemblies, and fails to load for some reason. In Visual Studio, I get (stripped down):
Error loading D:\xxx\Xxx.Test.dll: Unable to load the test container 'D:\xxx\Xxx.Test.dll' or one of its dependencies. Error details: System.BadImageFormatException: Could not load file or assembly 'Common.Geometry.Native, Version=1.1.4574.22395, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Running MSTest manually in a command prompt, I get:
Unable to load the test container 'D:\xxx\Xxx.Test.dll' or one of its dependencies. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Common.Geometry.Native, Version=1.1.4574.22395, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Details worth mentioning:
The test project itself is compiled using 'Any Cpu'.
I use a x64 specific testrunconfig
Dependency walker shows no missing native dependencies in the C++/CLI assembly (Common.Geometry.Native)
Even more interesting, there is another test project in the same solution using the same C++/CLI assembly (Common.Geometry.Native), and it runs without any problems.
I have also verified that there are no 32bit assemblies/dlls interfering.
Any suggestions is welcome !
I'd initially thought that microsoft didn't add a 64-bit capable test runner for MSTest until 2012... As it turns out, VS2010 is capable of this.
What I'd check then is if your native dll has any other native dependencies.
MSTest has a "mis-feature" where, before running your tests, it creates a temp directory, usually something like PC-NAME WORKSPACE_NAME 1782368124\Out, and it copies your code into that directory. For .NET assemblies, it can figure out the dependencies and is able to copy them, but for native code it does not appear to do this.
I've solved this in the past by adding the directory containing any other native dependencies to the PATH environment variable for my user account (remember if you do this to restart visual studio as it won't notice)

Running MsTest throws "Load" method does not have an implementation

After upgrading from TFS 2008 to 2010 and running crazy having the build to properly run unit tests.
When running unit tests from build or command line I get the error:
Loading C:\Builds\159....\Binaries\Mixed Platforms\Release....UnitTest.dll...
C:\Builds\159....\Binaries\Mixed Platforms\Release.....UnitTest.dll
Method 'Load' in type 'Microsoft.VisualStudio.TestTools.TestTypes.Unit.TestMethod' from assembly 'Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,
Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation.
Does any anyone have any clue, other then an repair of the VS?
The error was caused by some assembly redirect in unit test's app.config, which was redirecting System.Xml and one other assembly to 2.0 framework.
Probable mstest is replacing the original exception with a new one....

Resources