Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到URI或FriendlyName为的vstest测试记录器_C#_Vstest - Fatal编程技术网

C# 找不到URI或FriendlyName为的vstest测试记录器

C# 找不到URI或FriendlyName为的vstest测试记录器,c#,vstest,C#,Vstest,我正试图通过本文实现我的定制vstest记录器,在VS解决方案中我有3个项目 ClassLibrary1 仅包含一个示例服务类 public class Service { public int GetDocumentNumber(Guid documentId) { if (documentId == Guid.Empty) { throw new ArgumentExcep

我正试图通过本文实现我的定制
vstest
记录器,在VS解决方案中我有3个项目

ClassLibrary1 仅包含一个示例
服务

public class Service
    {
        public int GetDocumentNumber(Guid documentId)
        {
            if (documentId == Guid.Empty)
            {
                throw new ArgumentException("Document id is empty guid.");
            }

            return 178;
        }
    }
SimpleLoggerVSTest(类库) 只包含一个类。
ITestLogger
是来自
Microsoft.VisualStudio.TestPlatform.ObjectModel
的接口

[ExtensionUri("logger://SimpleConsoleLogger/v1")] /// Uri used to uniquely identify the console logger. 
[FriendlyName("SimpleLogger")] /// Alternate user friendly string to uniquely identify the logger.
        public class SimpleLogger : ITestLogger
        {
            public void Initialize(TestLoggerEvents events, string testRunDirectory)
            {
                Console.WriteLine("++++ Initialize ++++");
            }
        }
UnitTestProject 只包含一个测试类

[TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            // Arrange 
            Guid documentId = Guid.NewGuid();
            Service service = new Service();

            // Act
            var res = service.GetDocumentNumber(documentId);

            // Assert
            Assert.AreEqual(res, 178);
        }

        [TestMethod]
        public void TestMethod2()
        {
            // Arrange 
            Guid documentId = Guid.Empty;
            Service service = new Service();

            // Act
            var res = service.GetDocumentNumber(documentId);

            // Assert
            Assert.AreEqual(res, 178);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void TestMethod3()
        {
            // Arrange 
            Guid documentId = Guid.Empty;
            Service service = new Service();

            // Act
            service.GetDocumentNumber(documentId);
        }
    }
UnitTestProject
引用了第一个
ClassLibrary
SimpleLoggerVSTest

我厌倦了在VS2017的开发者命令提示符下执行以下命令

cd C:\Users\User\source\repos\Solution2\UnitTestProject1\bin\Debug
vstest.console.exe UnitTestProject1.dll /TestAdapterPath:. /Logger:SimpleLogger
我得到了以下错误:

找不到URI为或FriendlyName为“SimpleLogger”的测试记录器

我做错了什么?你能帮我吗


编辑:因此,我听说这可能是由旧版本的Visual Studio造成的。但是我有15.6.3。

确保SimpleLogger类存在于名称以testlogger.dll结尾的程序集中

@haim770我注释了
ExtensionUri
属性并使用了小写命令。这没用。我也犯了同样的错误,背后的逻辑是什么?我应该调用我的dll
something\u testlogger.dll
,对吗?或者你的回答是关于其他事情的(我不太清楚)?谢谢vstest.console.exe仅在以testlogger.dll结尾的程序集中查找
ITestLogger
实现。是的,它应该是某个东西\u testlogger.dll。