4

I have the test adapter & framework packages added per the docs https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing-faq?view=vs-2017.

I see the "beaker" symbol\icon beside each test, but hovering says it's Excluded from live unit testing.

Tests all run fine MANUALLY, and I've tried right-clicking and telling it to include, but does nothing. I have no code in here manually excluding anything...

.net 4.7.1 project

EDIT

There is an error

[10:03:48.205 Error] [TestRunner 1] An exception occurred while invoking executor 'executor://mstestadapter/v2': Could not load file or assembly 'System.Xml.ReaderWriter, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'System.Xml.ReaderWriter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

This is a 4.7.1 project testing another 4.7.1 project which is EFCore based.

Steve McNiven-Scott
  • 1,770
  • 2
  • 15
  • 29
  • Rogue attribute maybe? https://stackoverflow.com/questions/47157050/live-unit-testing-exclude-tests – Davesoft Aug 24 '18 at 13:24
  • Really appreciate the help man... no attributes or anything, opening the folder in VSCode doesn't even show anything https://www.dropbox.com/s/clz1b5iqys6hmmh/exclude.PNG?dl=0 – Steve McNiven-Scott Aug 24 '18 at 13:28

4 Answers4

2

I was getting a similar the same error, in out output window in the "Live Unit Testing" category, I found the following error:

FatalError - System.AggregateException: One or more errors occurred. ---> System.Exception: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I downloaded the latest version of that nuget package and it did not help, I basically had to force the 4.0.0.0 version in the config file which doesn't make much sense due to the fact that the actual version of the dll is 4.1.2.0. Any way, after that I stopped and started Live Unit Testing and now it works without a problem. Hope this helps.

<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.0.0.0" />
FabianVal
  • 374
  • 1
  • 7
2

For those still running into this issue, what fixed it for me was:

  1. Close visual studio
  2. Open your solution folder in the file explorer
  3. Delete the .vs folder (this may be hidden depending on your settings)
  4. Re-open the solution and run live unit testing.

This will blow away some of your local settings for the solution, so be aware of that. Things like the default startup project, debug parameters, etc. will be lost.

Isaac
  • 96
  • 1
  • 5
0

"Could not load file or assembly" can have different causes: wrong assembly reference or wrong assembly redirection.

  • In the first case, you can add an assembly redirection (FabianVal's answer)

[0] https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions

  • In the second case, you can correct or delete the redirection. I had wrong redirection introduced after update-package -reinstall, and I had to reedit the csproj files by deleting the wrong redirection.

A quick grep may help to find the culprit: get-childitem -recurse *csproj | select-string -patte rn "System.Runtime, Version=4.0.0.0"

Soleil
  • 6,404
  • 5
  • 41
  • 61
0

I have seen this happening as a result of the test project having a different platform target than the original project.

This can be fixed in Visual Studio under Build -> Configuration Manager

yoel halb
  • 12,188
  • 3
  • 57
  • 52