我想向NUnit添加自定义测试报告器。我已经用NUnit2做了,但我现在需要使用NUnit3。我的解决方案中有2个项目 记者项目 2.测试项目
在测试项目中,我有一个nunithook文件,该文件与包含NunitRegistrar的记者项目挂钩。
这样我可以"听" nunit框架事件。 我已经更新到nunit 3.8.1,我发现一切都已经改变了,这种灵魂不再适用了。
这是两个文件的实现:
using Reporter.Nunit;
using NUnit.Core.Extensibility;
namespace NunitHook
{
[NUnitAddin(Name= "NUnitHook", Description = "NUnit Hook")]
public class NUnitHook : NunitRegistrar
{
}
}
using System;
using System.IO;
using System.Linq;
using NUnit.Core.Extensibility;
namespace Reporter.Nunit
{
[NUnitAddin(Name = "EventListnerForReport", Description = "Event listener that listens to the tests and dispatches the events to the report manager")]
public class NunitRegistrar : IAddin
{
private bool registeredListeners;
public bool Install(IExtensionHost host)
{
if (!registeredListeners)
{
if (host == null)
{
throw new ArgumentNullException("host");
}
IExtensionPoint listeners = host.GetExtensionPoint("EventListeners");
if (listeners == null)
{
return false;
}
listeners.Install(new TestEventListener());
registeredListeners = true;
return true;
}
return true;
}
}
}
有一种简单的方法可以将它转换为nunit 3吗?
谢谢!