xunit / xamarinstudio.xunit

xUnit.net support for Xamarin Studio
http://addins.monodevelop.com/Source?projectId=220
Other
31 stars 14 forks source link

Please uninstall this extension as Visual Studio for Mac/MonoDevelop natively supports xUnit.net now #77

Open lextm opened 6 years ago

lextm commented 6 years ago

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/

Visual Studio Test Platform (VSTest) support. Visual Studio for Mac now supports a wider variety of test frameworks through the integration of VSTest, giving developers more choice in the test frameworks they want to use. Frameworks such as MSTest or xUnit can now be used within Visual Studio for Mac via NuGet adapter packages.

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.

lextm commented 6 years ago

MonoDevelop 7 ships the same VSTest integration, so no other extension is needed either.

usr-sse2 commented 6 years ago

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.

roman-yagodin commented 6 years ago

@usr-sse2, you could try this:

  1. Add new tests project of type .NET Core / Tests / xUnit Tests Project.
  2. Move your test classes to the new project.
  3. Reference your non- .NET Standard project in the tests .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.

lextm commented 6 years ago

@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.

roman-yagodin commented 6 years ago

@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>
usr-sse2 commented 6 years ago

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.