Open lextm opened 6 years ago
MonoDevelop 7 ships the same VSTest integration, so no other extension is needed either.
How to make Visual Studio for Mac see tests without this plugin, if my project is for Mono? It seems to see them only for .NET Core.
@usr-sse2, you could try this:
.csproj
manually:<ItemGroup>
<ProjectReference Include="..\YourBaseProject\YourBaseProject.csproj" />
</ItemGroup>
This works for me on Mono 5.10 and MonoDevelop 7.4 with only few quirks, like the рroject reference displayed with error "Incompatible target framework..."
More safe approach would be to move all your code which should be testable into the separate .NET Standard 2.0 library project. Then you could reference it in the tests project (which is .NET Core) and in the main project (could be full .NET Framework or Mono or .NET Core). But this will have ts drawbacks - more projects/assemblies to manage, sometimes need major code rework to ensure testability w/o referencing something outside .NET Standard like WPF or WebForms.
@usr-sse2 You need to add a few NuGet packages, including xUnit Visual Studio runner. Make sure Visual Studio 2017 can discover the test cases, and then Visual Studio for Mac and MonoDevelop 7.x on Linux should do the same.
@roman-yagodin I have no problem running Mono based projects. There seems to be no need to convert to .NET Standard projects.
@lextm You need to add a few NuGet packages, including xUnit Visual Studio runner
Seems like just adding xunit.runner.visualstudio
package fixed my tests discovery issues with MonoDevelop 7.4 w/o converting projects to .NET Core / .NET Standard - my thanks!
My packages.config
file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.1.0" targetFramework="net45" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
<package id="xunit.assert" version="2.1.0" targetFramework="net45" />
<package id="xunit.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.3.1" targetFramework="net45" developmentDependency="true" />
</packages>
It оказалось, that Visual Studio for Mac doesn’t find XUnit tests if both XUnit and NUnit are referenced in the same project. Removing NUnit reference fixed the problem.
Microsoft announced VSTest support in Visual Studio for Mac 7.3,
https://blogs.msdn.microsoft.com/visualstudio/2017/12/04/visual-studio-2017-version-15-5-visual-studio-for-mac-released/
This marks the end of this separate extension to hook xUnit.net with VS for Mac.
Please uninstall this extension and enjoy the built-in support.