Skip to content
This repository has been archived by the owner on Oct 16, 2018. It is now read-only.

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

Open
lextm opened this issue Dec 5, 2017 · 6 comments

Comments

@lextm
Copy link
Collaborator

lextm commented Dec 5, 2017

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
Copy link
Collaborator Author

lextm commented Dec 14, 2017

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

@lextm lextm changed the title Please uninstall this extension as Visual Studio for Mac natively supports xUnit.net now Please uninstall this extension as Visual Studio for Mac/MonoDevelop natively supports xUnit.net now Dec 14, 2017
@usr-sse2
Copy link

usr-sse2 commented Feb 7, 2018

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
Copy link

roman-yagodin commented Mar 13, 2018

@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
Copy link
Collaborator Author

lextm commented Mar 14, 2018

@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
Copy link

roman-yagodin commented Mar 14, 2018

@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
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants