问题
I am running Visual Studio on Mac (Preview 5, latest) and I am trying to get unit testing with Xunit working.
I created a new project for .NET Core -> Tests which creates the following sample code
using System;
using Xunit;
namespace SMASHDOCsTests
{
public class UnitTest1
{
[Fact]
public void testFoo()
{
return;
}
}
}
I am able to compile the code properly however I can not execute the tests.
It always complains with "Internal error: unable to run tests, test discovery failed".
How can I track this error down or resolve it?
回答1:
My current version of Visual Studio for Mac is (v7.0.1.24) -- this is how I resolved the issue with the internal warnings:
Update the package nugget (located in fileTree sidebar)
Follow the instructions on this page and install the extension. Note the exception for mac:
IMPORTANT: Starting from v0.7.3, please download the .mpack files from https://github.com/xunit/xamarinstudio.xunit/releases Then in Extension Manager you can use "Install from file..." button to manually install this extension.
This let's me run my tests and gives me feedback in the UI:
[TestFixture()]
public class Test
{
[Test()]
public void TestCase()
{
int a = 100;
int b = 100;
Assert.AreEqual(a, b);
}
}
来源:https://stackoverflow.com/questions/43328489/tests-not-picked-up-with-xunit-testrunner-on-visual-studio-on-mac-c-net-core