1

I have a Xamarin forms project that I'm running on an Intel Mac. We are using XUnit for unit testing, and I would like to be able to run the tests on the command line on my Mac. The tests run inside the IDE but I can't get them to run on the command line. I have tried many different options and nothing seems to work. The current way I'm trying to get the tests to run is by using the XUnit cli tool.

I have dotnet installed and on my path, running
dotnet --version
returns
6.0.110

I installed xunit-cli with the following command
dotnet tool install -g xunit-cli

and I've added xunit on my path, however, when I run the xunit-cli I get the following error

You must install .NET to run this application.

App: /Users/luke/.dotnet/tools/xunit
Architecture: x64
App host version: 6.0.10
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.13-x64&apphost_version=6.0.10

What part of my setup is incorrect?

TheLukeMcCarthy
  • 2,253
  • 2
  • 25
  • 34

1 Answers1

0

Do you really need to use xunit-cli?

You can simply install the Microsoft.NET.Test.Sdk NuGet package in your test project and use dotnet test instead:

dotnet test MyProject.csproj
Cheesebaron
  • 24,131
  • 15
  • 66
  • 118
  • I've tried that and I get the following error ```Testhost process exited with error: Cannot open assembly '/usr/local/Cellar/dotnet/6.0.110/libexec/sdk/6.0.110/Extensions/..//TestHost/testhost.net472.x86.exe': No such file or directory. . Please check the diagnostic logs for more information. Test Run Aborted.``` I've also tried with the `-f netstandard2.0` option and `-f netcoreapp3.1` and they don't work either – TheLukeMcCarthy Dec 19 '22 at 22:56
  • You test project is targeting which target framework? – Cheesebaron Dec 20 '22 at 14:54