Search code examples
c#nunit-3.0visual-studio-test-runnernunit-addins

Using NUnit3 addins with VS Test Adapter


I created a very simple NUNit3 addin (see code below), but I'm not sure how to actually make it run when I kick off tests using the Visual Studio Test Adapter in VS2015. I've built it into an assembly, but I'm not sure where I need to reference it.

Addin code:

using NUnit.Engine;
using NUnit.Engine.Extensibility;
using System.IO;
using System.Xml;

namespace NUnit.ExtentReportingAddin
{
    [Extension(Description = "Test Reporter Extension", EngineVersion = "3.4")]
    public class MyEventListener : ITestEventListener
    {
        public void OnTestEvent(string report)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(report);
            xmlDoc.Save("outputtest.xml");
        }
    }
}

To verify my addin is working correctly I installed the NUnit3 Console runner, updated it's nunit.engine.addins file, and ran my tests through it. Upon running my tests, the outputtest.xml was successfully generated/updated at every step of the test run.

The documentation mentions creating a ".addins" file where the engine is located that references my assembly, but I'm not sure where the engine is running from since I'm running the tests using the test adapter. As far as I can tell I just need to know where to put the files when working with the VS Test Adapter, or if this scenario is even an option.


Solution

  • I faced the same problem. According to this, NUnit3TestAdapater does not support addins/extensions (yet):

    https://github.com/nunit/nunit3-vs-adapter/issues/222

    They are planning to make it work with the 4.0 version:

    https://github.com/nunit/nunit3-vs-adapter/milestone/17