0

I am running NUnit 3.6 in VS 2015 and trying to create extenstion (Addon ) for NUnit , but so far the NUnit is not detecting the addon , I put its path it in .addins file , and every thing the documentation saying but no luck . if I run the unit test from console it does detect the addon as expected Here is the code :

using NUnit.Engine;
using NUnit.Engine.Extensibility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.WebRequestMethods;

namespace AddOn
{
    [Extension]
    [TypeExtensionPoint(
    Description = "Test addon " )]

    public class NUnitMonitor : ITestEventListener
    {
        public void OnTestEvent(string report)
        {
            System.IO.File.WriteAllText(@"D:\report.txt", report);
            System.Diagnostics.Debug.WriteLine("TEST Report here : ", report);

        }
    }
}
sino
  • 754
  • 1
  • 7
  • 22

1 Answers1

1

One error in your code: Extension Points are defined in NUnit itself, not in your code. They are the points where NUnit can be extended. So, the TypeExtensionPointAttribute has no effect in your code, although it isn't hurting anything.

Since you are able to run the extension when using the console runner, you have installed it there correctly. However, when running under Visual Studio with the NUnit 3 Test Adapter, you aren't using that copy of the NUnit engine. Instead, you are using a private copy that is embedded in the adapter itself.

Although it's undocumented, you can get an extension to run by creating an .addins file in the same directory where the engine is installed, with the path to your extension location contained in it. This is generally only practical if you installed the adapter through its nuget package.

In that case, take the following steps:

  1. Copy your addin to a convenient location in your project directory.
  2. Create a file with extension .addins in the same directory where the engine assembly was installed by nuget.
  3. Add a line to the .addins file with the path to your extension assembly.
Charlie
  • 12,928
  • 1
  • 27
  • 31