Tests not picked up with XUnit testrunner on Visual Studio on Mac (C#, .net Core)

时间秒杀一切 提交于 2019-12-07 21:12:27

问题


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:

  1. Update the package nugget (located in fileTree sidebar)

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



来源:https://stackoverflow.com/questions/43328489/tests-not-picked-up-with-xunit-testrunner-on-visual-studio-on-mac-c-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!