kbilsted / StatePrinter

Automating unit testing and ToString() coding
Apache License 2.0
93 stars 32 forks source link

Tests don't run in Visual Studio 2017 #59

Closed harrybellamy closed 5 years ago

harrybellamy commented 5 years ago

When attempting to run the tests in VS 2017 (Enterprise v15.9.2) it gives the following error when attempting to run all tests. As suggested, I upgraded the test project to Framework v4.0 and all tests could be run.

[15/01/2019 13:49:51 Informational] ------ Discover test started ------
[15/01/2019 13:49:51 Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Framework35 is not supported. For projects targeting .Net Framework 3.5, please use Framework40 to run tests in CLR 4.0 "compatibility mode".
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.UpdateRunSettingsIfRequired(String runsettingsXml, List`1 sources, String& updatedRunSettingsXml)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.DiscoverTests(DiscoveryRequestPayload discoveryPayload, ITestDiscoveryEventsRegistrar discoveryEventsRegistrar, ProtocolConfig protocolConfig)
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.<>c__DisplayClass20_0.<StartDiscovery>b__0()
[15/01/2019 13:49:51 Informational] ========== Discover test finished: 0 found (0:00:00.3566916) ==========
[15/01/2019 13:49:57 Informational] ------ Run test started ------
[15/01/2019 13:49:57 Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Framework35 is not supported. For projects targeting .Net Framework 3.5, please use Framework40 to run tests in CLR 4.0 "compatibility mode".
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.UpdateRunSettingsIfRequired(String runsettingsXml, List`1 sources, String& updatedRunSettingsXml)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.RunTests(TestRunRequestPayload testRunRequestPayload, ITestHostLauncher testHostLauncher, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig)
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.<>c__DisplayClass19_0.<StartTestRun>b__0()
[15/01/2019 13:49:57 Informational] ========== Run test finished: 0 run (0:00:00.026926) ==========
kbilsted commented 5 years ago

thanks

kbilsted commented 5 years ago

Sounds like you are missing a dependency on your machine. Should we break compatibility for that reason?

harrybellamy commented 5 years ago

Have you got a list of dependencies I can check against my machine? This may also have an implication on #52 - to build against .Net Standard VS 2017 (or later) will be required.

kbilsted commented 5 years ago

.net framework 3.5

harrybellamy commented 5 years ago

.Net Framework 3.5 is installed on my machine according to my registry. To be clear, the test project does build against .Net 3.5 (I would expect it not to if that dependency was missing), the tests just won't run.

kbilsted commented 5 years ago

Im running them through resharper

harrybellamy commented 5 years ago

That might explain this, I'm just using the standard Test Explorer in Visual Studio. Resharper is not installed on this machine.

kbilsted commented 5 years ago

I dont think appveyor is using resharper though :)

harrybellamy commented 5 years ago

Appveyor uses MSBuild v14.0 as it auto-detects the version (presumably from the solution file):

MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'.

v14.0 ships with VS 2015.

kbilsted commented 5 years ago

i can also run tests directly on my VS 15.9.1, from 2017 without problems.

kbilsted commented 5 years ago

i've upgraded to 4.6.1 now. still having issues?

harrybellamy commented 5 years ago

Unfortunately so - a different set of issues though:

[20/01/2019 14:38:03 Informational] ------ Discover test started ------
[20/01/2019 14:38:05 Warning] No test is available in C:\HarryBellamy\Sandbox\StatePrinterTest\StatePrinter.Tests\StatePrinter.Tests.csproj C:\HarryBellamy\Sandbox\StatePrinterTest\StatePrinter\StatePrinter.csproj. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[20/01/2019 14:38:05 Informational] ========== Discover test finished: 0 found (0:00:02.1892294) ==========
[20/01/2019 14:38:10 Informational] ------ Run test started ------
[20/01/2019 14:38:11 Informational] Test project StatePrinter.Tests does not reference any .NET NuGet adapter. Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
[20/01/2019 14:38:11 Informational] ========== Run test finished: 0 run (0:00:00.7964452) ==========

The tests are visible in the Test Explorer, I just get the above issue if I try running them.

kbilsted commented 5 years ago

Hard for me to help when I cant reproduce. Maybe another runner is needed ?

harrybellamy commented 5 years ago

I've added the NUnit 3 test adapter via NuGet and the tests can now be run. Created PR #61 with this addition.