When I run my Unit Tests, all tests pass, but instead of "Test run succeeded" or whatever the success message is, I get "Test run error" in the little bar that tells me how many of my tests pass, even though all my tests passed.
When i click the text, I'm taken to a page that tells me the following two things happened:
Warning: conflict during test run deployment: deployment item '[...]\Booking.Web.dll' directly or indirectly referenced by the test container [...]\Booking.Web.Tests.dll cannot be deployed to 'Booking.Web.dll' because otherwise the file '[...]\Booking.Web.dll' would override deployment item '[...]\Booking.Web.dll' directly or indirectly referenced by '[...]\Booking.Web.Tests.dll'
Error: Cannot initialize the ASP.NET project 'Booking.Web'
Exception was thrown: The website could not be configured correctly; getting ASP.NET proccess information failed. Requesting 'http://localhost:54131/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (500) Internal Server Error.
I don't understand half of what it's complaining about. How do I get rid of these errors?
(And for reference: Booking.Web is an ASP.NET MVC 2 project, Booking.Web.Tests is a Test project, [...] is the full local path to the projects in my environment, in most of the cases above to the /bin/debug/ folder inside the Booking.Web project)
Update: As instructed, I looked for more info in Event Viewer. Here's what I found:
3008
A configuration error has occurred.
5/8/2010 2:26:15 AM
5/8/2010 12:26:15 AM
4ffbe9180c3d4c02adb9ac4d61dd0928
1
1
0
4484bbf4-1-129177519750954331
Full
/
D:\...\Booking.Web\
AASLOEG
1876
WebDev.WebServer40.EXE
Aasloeg\Tomas
ConfigurationErrorsException
Could not load file or assembly 'Ninject.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=79764a4ef1548af1' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045) at
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) at
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() at
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) at
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) at
...stack trace in absurdum.
First of all - you have Code Coverage enabled. You can read here about it. So there is no problems with Unit Tests. This is code coverage problem.
Second thing - this warning is ok - never mind about it.
Third thing - this error - this is the key problem.
There can be different problems - most common is that you should refference more assemblies. To find out what exactly should be loaded you must go to Event Viewer and look at at Windows Logs->Application
I had the same error related to MS-Test complaining that a DLL could "override deployment item blah.dll".
This was happening because I was running MS-Test for multiple DLL's at once like so:
mstest.exe /testcontainer:Tests.web.dll /testcontainer:Tests.svcs.dll /testcontainer:Tests.core.dll
When MS-Test was running this, it tried to take all the output DLL's from the tests and place them in out /Out directory of the test run. In my case, Tests.svcs.dll and Tests.core.dll both referenced the same assembly (Core.dll) and therefore it tried to copy that DLL to the same spot twice (thus causing the warning).
To resolve this, I separated the test runs for each assembly which gave each test run it's own /Out folder for output DLL's
mstest.exe /testcontainer:Tests.web.dll
mstest.exe /testcontainer:Tests.svcs.dll
mstest.exe /testcontainer:Tests.core.dll
Related
I started with Among Us mod making a few days ago, I set everything up and followed the instructions listed on this page (https://docs.reactor.gg/docs/) and everything worked. I could build my mods and it would work as intended. 2 days ago, out of the blue all of my imports (like the UnityEngine import and other external imports) were throwing 'does not exist in this current context errors' The root of this (I found) was this:
Severity Code Description Project File Line Suppression State
Error MSB4018 The "GenerateReferences" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' or one of its dependencies. The system cannot find the file specified.
File name: 'Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'
at Il2CppDumper.DummyAssemblyExporter.Export(Il2CppExecutor il2CppExecutor, String outputDir, Boolean addToken)
at Il2CppDumper.Il2CppDumper.PerformDump(String gameAssemblyPath, String metadataDatPath, String outputDirectoryPath, Config config, Action`1 reportProgressAction)
at Reactor.OxygenFilter.MSBuild.GenerateReferences.Execute() in /home/js6pak/Development/AmongUs/Reactor.OxygenFilter/Reactor.OxygenFilter.MSBuild/GenerateReferences.cs:line 56
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].REDACTED.REDACTED]
I have tried reimporting, and redoing everything from scratch (like redownloading BepinEx, Reactor, Among Us) and have also tried building a fresh project, but even new projects don't seem to build. Is there something wrong on my part?
Turns out, I had to downgrade my Among Us version. The way I downgraded the version was using Docker, but I suppose any other way could work.
I have a .NET Core v2.2 application. I am trying to start Selenium UI tests, built on top of unit testing project (tried using NUnit, xUnit).
The tests can be started locally from VS(using TestExplorer), or from started locally .NET Core 2.2 app.
The goal is to be able to start test, once the app is deployed in IIS, using button in a view.
I've tried both starting the test using reflection, and instantiating the class, or starting it as process (by running nunit3-console.exe, dotnet test or vstest.console.exe) in command line.
When using
dotnet test {PathToTestDll} --filter "Name ~{testName}" --logger trx --results-directory {resultDir}
command, I can start the test from cmd, but when trying to open the published site, I get error for missing dll
Could not load file or assembly 'Microsoft.VisualStudio.Coverage.CoreLib.Net, Version=16.9.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.), which is part of VS Enterprise, I am currently using VS Professional 2019 Version 16.9.1.
If I try and use
nunit3-console.exe --test={testFullyQualifiedName} {PathToTestDll}
I get another error for missing nunit.framework package:
NUnit.Engine.NUnitEngineException : An exception occurred in the driver while loading tests.
System.IO.FileNotFoundException : Could not load file or assembly 'nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies. The system cannot find the file specified.
--NUnitEngineException
An exception occurred in the driver while loading tests.) regardless if I execute it in the dir, where the nunit.framework file is located (C:\Users{user}.nuget\packages\nunit{version}), or the published project's dir (somewhere in C:\inetpub\wwwroot{projectName}).
Now when using reflection, after the app is published, the test fail, with the same error (javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite. (Session info: chrome=88.0.4324.190)), which is a Selenium error, for using not unique way to locate element, if I am not mistaken. For each test. I've checked them and can assure you, it is not the case.
By this time, I have accepted that I am doing something, or everything wrong, but cannot pin-point what.
I have to say, that I currently use NUnit3, chromedriver v88.0.4324.96, Selenium.WebDriver 3.141.0
We have a big bunch of tests(6000+) in differents assemblies. We run them on a local Azure Agent, with the Nunit Test adapter.
It was taking a very long time, so we activated the runInParallel.
The yaml step is now the following:
- task: VSTest#2
timeoutInMinutes: 300
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: '*.Test*.dll'
searchFolder: '$(System.DefaultWorkingDirectory)/$(buildConfiguration)'
codeCoverageEnabled: false
platform: 'Any CPU'
uiTests: false
configuration: '$(buildConfiguration)'
rerunFailedTests: false
pathtoCustomTestAdapters: 'Solution/packages/NUnit3TestAdapter.3.12.0/build/net35'
minimumExpectedTests: 1000
runInParallel: true
distributionBatchType: basedOnAssembly
failOnMinTestsNotRun: true
resultsFolder: 'testResults'
runSettingsFile: '$(Build.SourcesDirectory)\azure-tests.runsettings'
#continueOnError: true
Now, we get some tests that doesn't pass. I've analyzed one of them, and basically, it fails because at some point, it does a OfType<SomeInterface>. The objects in the collection does implement this interface, so I guess I must have an issue with this assembly loaded 2 time and this interface not being considered the same as the created objects.
When I check the logs, I now see this, which seems to confirm this theory:
##[warning]RunMessage : Exception NUnit.Engine.NUnitEngineUnloadException, Exception thrown unloading tests from C:\DevOp\2\s\debug\Acceptance.Tests.dll
##[warning]RunMessage : Exception encountered unloading application domain
##[warning]RunMessage : at NUnit.Engine.Services.DomainManager.DomainUnloader.Unload()
at NUnit.Engine.Runners.TestDomainRunner.UnloadPackage()
at NUnit.Engine.Runners.AbstractTestRunner.Dispose(Boolean disposing)
at NUnit.Engine.Runners.AbstractTestRunner.Dispose()
at NUnit.Engine.Runners.MasterTestRunner.Dispose(Boolean disposing)
at NUnit.Engine.Runners.MasterTestRunner.Dispose()
at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, TestFilter filter) in D:\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 321
##[warning]RunMessage : Innerexception: NUnit.Engine.NUnitEngineException: Exception encountered unloading application domain: Error while unloading appdomain. (Exception from HRESULT: 0x80131015)
Application domain name: domain-dcec2bc8-Acceptance.Tests.dll
Application domain BaseDirectory: C:\DevOp\2\s\debug\
I've searched, but I didn't found how to solve this issue. I can understand, that I probably have something that prevent the assembly to properly unload, but we have more than 6000 tests, 15 tests assemblies which references some production code and some test code. The execution of all tests takes ~2h45.
How do I know what cannot be unloaded(and why?) How would you proceed to solve this error?
Issue: On my development machine, everything works fine. However, when I copy the executable to the server, my program doesn't start
What I've done so far: I checked the event viewer and the error stack looks like this:
Application: Project.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
Stack:
at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
at System.Configuration.ConfigurationManager.GetSection(System.String)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
at Project.BaseService..ctor()
at Project.Service..ctor()
at Project.Program.Main()
I checked online and, most of the times, this error is generated by some misplacement of configSections on the .config files. To make sure this was not the case, I let both app.config and .exe.config files clean (only the section was there), but my program still didn't work.
Then, I generated a dump file from the failing process and here is where things get strange: the exception that is thrown when I'm calling ConfigurationManager.ConnectionStrings is "Configuration System failed to initialize", with a "The 'add' start tag on line 257 position 6 does not match the end tag of 'connectionManagement'. Line 258, position 3." inner exception. I double-checked my entire project and there is not a single reference to "connectionManagement" anywhere! I even tried to check AppDomain.CurrentDomain.SetupInformation.ConfigurationFile's value and it indicates the right config file.
By fixing this connectionManagement issue I'll probably be able to run my application, but do you guys have any idea about where this might be coming from?
Problem was on the machine.config file on the server. Changing it solved the problem!
I found that one of my tests that passes in VS2013 is failing in VS2015, the test calls a service that includes among other things a call to Console.Clear();
to find out whats going on I made a simple unit test
[TestMethod]
public void ExampleTest()
{
Console.Clear();
}
This test passes in visual studio 2013 but in 2015 I get the following error:
Test Name: ExampleTest
Test FullName: solution.Common.Test.CacheManagerTest.ExampleTest
Test Source: C:\solution.Common.Test\CacheManagerTest.cs : line 34
Test Outcome: Failed
Test Duration: 0:00:00.3015003
Result StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode,
String maybeFullPath) at System.Console.GetBufferInfo(Boolean
throwOnNoConsole, Boolean& succeeded) at System.Console.Clear()
at sol.Common.Test.CacheManagerTest.ExampleTest() in
C:\solution.Common.Test\CacheManagerTest.cs:line 35 Result Message:
Test method Alexandria.Common.Test.CacheManagerTest.ExampleTest threw
exception: System.IO.IOException: The handle is invalid.
I do understand that it is bad design for my service to fail if it is not called by a console. The reason I am asking this question is to understand why this is failing in the new version of Visual Studio. Is this the intended behavior? What changed?
I did not see anything obvious in the change log that would seem related to this.
Edit: I am calling the Console.clear from the following dll
Microsoft\Framework.NETFramework\v4.5.1\mscorlib.dll
Edit 2:
picture of testproject properties in both visual studios
The changes in VS2015 are pretty visible, use the Test > Debug > All Tests to get insight. You can see that it now has a new test host process, its name is TE.ProcessHost.Managed.exe, stored in the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow directory.
Previous versions of VS used a different host, vstest.executionengine.exe. One notable change in the new test host is that it is no longer a console mode program. Something you can see by running Dumpbin.exe /headers on the exe.
Another way to see the underlying problem is with Task Manager. Note how running a test in an older VS version causes a conhost.exe process to get added. This is the process that owns the console window for a console mode app. A problem I've seen before is that this process tends to leak, not terminating when the test completes. Adding ever more conhost.exe instances, at one point researching this problem I had 12 of them running. Presumably the changes in VS2015 were meant to address that problem.
Technically you can configure the unit test with a .runsettings file and use the <ForcedLegacyMode> element to force the old test host process to be used. This however has no effect on the outcome of this test, looks like they addressed this in multiple ways.
That's a fair amount of guessing, I recommend you use connect.microsoft.com to file a feedback report. You can quote this Q+A for reference.
Meanwhile, you can consider a workaround. Do note that Console.Clear() is in general a trouble-maker, it will also fail in normal usage when the output of a console mode app is redirected. Very easy to do from a command line prompt with the > operator. Which is the ultimate reason it fails in a unit test. You'll want to make the code resilient so it can work properly both in production and in a unit test. Like this:
if (!Console.IsOutputRedirected) Console.Clear();
Which requires targeting .NET 4.5 or higher. You can use the code in this SO post if you need to target earlier versions.