Using NUnit EventListeners Addin with ReSharper 7

775 views Asked by At

I've defined an Addin for NUnit (2.6.0) like so

namespace company.Testing.Attributes
{
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class ThenWithSetupAttribute : TestAttribute
    {}
}

namespace company.Testing
{
    [NUnitAddin(Description = "ThenWithSetup", Name = "ThenWithSetup")]
    public class ThenWithSetup : IAddin, EventListener
    {    
        public void RunStarted(string name, int testCount)
        {}

        public void RunFinished(TestResult result)
        {}

        public void RunFinished(Exception exception)
        {}

        public void TestStarted(TestName testName)
        {
            throw new Exception("Hello");
        }

        public void TestFinished(TestResult result)
        {
            throw new Exception("I said hello!");
        }

        public void SuiteStarted(TestName testName)
        {}

        public void SuiteFinished(TestResult result)
        {}

        public void UnhandledException(Exception exception)
        {}

        public void TestOutput(TestOutput testOutput)
        {}

        public bool Install(IExtensionHost host)
        {
            IExtensionPoint listeners = host.GetExtensionPoint("EventListeners");

            if (listeners == null)
                return false;

            listeners.Install(this);
            return true;
        }
    }
}

Using Visual Studio 2010 and ReSharper 7 I was under the impression that, when I've also set ReSharper -> Options-> Nunit -> Load NUnit Addins -> Always AND put the company.Testing.dll in the ..\ReSharper\v7.0\Bin\addins folder, those eventlisteners would fire (throwing an exception in this case). This is not the case however, the test runs sucessfully when it should fail in the TestStarted-eventlistener!?!

My test, defined in another solution (referenceing the above .dll):

[ThenWithSetup]
public void ShouldGetOkResponse()
{
    Console.WriteLine("testing 123");
    Assert.AreEqual(HttpStatusCode.OK, _result.StatusCode);
}

I missing something obviously, but what?

Thanks!

1

There are 1 answers

0
razon On

may be your dll with tests contains nunit packages for addins? For me this case doen't work. After removing packages all begun work.

look my answer here: https://stackoverflow.com/a/34154702/908936