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