Tests not picked up with XUnit testrunner on Visua

2019-05-21 00:57发布

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条回答
放我归山
2楼-- · 2019-05-21 01:47

My current version of Visual Studio for Mac is (v7.0.1.24) -- this is how I resolved the issue with the internal warnings:

  1. Update the package nugget (located in fileTree sidebar)enter image description here

  2. 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);
    }
}

enter image description here

查看更多
登录 后发表回答