I am trying to implement an custom event listener as shown below
public class CustomEventListener: ITestEventListener
{
public void OnTestEvent(string report)
{
using (StreamWriter writer = new StreamWriter(@"D:\LogFile.txt"))
{
writer.WriteLine(report);
}
}
}
i have implemented this in a separate project called Extension.csProj. How do i integrate this to n-unit runner? I want this extension to be pickedup automatically for all the tests.
Please let me know how i can do that or any documentation explaining the same
The ITestEventListener
interface is used for one type of extension supported by the NUnit TestEngine
. Code such as you posted would be part of an extension. Other boilerplate is needed, which you may or may not have.
Documentation for creating engine extensions is part of the NUnit docs and may be found at https://docs.nunit.org/articles/nunit-engine/extensions/creating-extensions/Index.html
I suggest reading the full documentation and experimenting a bit. Ask another question if you run into a specific problem.
One thing the docs do not give you is how or where to install the extension. Unfortunately, that varies depending on what runner you are using and how it was installed. As a start,
.addins
.